Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Jun 27, 2014 4:01 pm

Hi,

I am coding in VB.net, converting from word interop. I am trying to convert the following code, but I cannot find a similar option for MoveEnd, Copy or PasteSpecial. Is it possible to convert this routine?

public sub A (ByRef objSourceDocument As Spire.Doc.Document, ByRef objDestinationDocument As Spire.Doc.Document)

If (Not (objDestinationDocument Is Nothing) And Not (objSourceDocument Is Nothing)) Then
objSourceDocument.Select()
objSourceDocument.Windows.Item(1).Selection.MoveEnd(Unit:=Interop.Word.WdUnits.wdCharacter, Count:=-1)

selectionCount = (objSourceDocument.Windows.Item(1).Selection.End - objSourceDocument.Windows.Item(1).Selection.Start)
If selectionCount > 0 Then
objSourceDocument.Windows.Item(1).Selection.Copy()
objDestinationDocument.Select()
objDestinationDocument.Windows.Item(1).Selection.PasteSpecial()
End If
End If

end sub

stevenheggie
 
Posts: 60
Joined: Tue Jun 24, 2014 10:32 am

Mon Jun 30, 2014 7:53 am

Hello,

Thanks for your inquiry.
There is some codes for how to replicate template for your reference.
Code: Select all
Dim objSourceDocument As New Document()objSourceDocument.LoadFromFile("template.docx")
Dim objDestinationDocument As New Document()
objDestinationDocument.Sections.Add(objSourceDocument.Sections(0).Clone())
objDestinationDocument.SaveToFile("result.docx", FileFormat.Docx)

If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Jun 30, 2014 9:40 am

Hi,

Thanks for your reply.

Is there an option for paste special in spire? As i need to convert this or is saving the document the only option?

objDestinationDocument.Windows.Item(1).Selection.PasteSpecial()

Also is there an option in spire to delete a document? As i need to convert the following:

objTempMergeDocument.Windows.Item(1).Selection.Delete()

Can this code be converted:
dim selectionCount as integer = (objSourceDocument.Windows.Item(1).Selection.End - objSourceDocument.Windows.Item(1).Selection.Start)

stevenheggie
 
Posts: 60
Joined: Tue Jun 24, 2014 10:32 am

Tue Jul 01, 2014 9:28 am

Hello,

In Spire, you can use the clone() method to copy the content of one document to another document like
Code: Select all
objSourceDocument.Sections(0).Clone()

Regarding the issue about deleting a document, if you want to delete a document on the disk, you can directly use the following method.
Code: Select all
 File.Delete(string Path);

or you want to delete the content of a document, you can use SPire like this.
Code: Select all
Document document = new Document();
document.LoadFromFile("Microsoft Word Document.docx");
document.Sections.Clear();

According to the simple codes, maybe the method we provide is not what you need. You could provide us the document and describe what you manage to implement, and we can provide you the corresponding solution.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Jul 04, 2014 9:15 am

Hello,

Do these codes fulfill your needs? Could you please give us some feedback if convenience? If not, please provide us the document and describe what you manage to implement, and we can provide you the corresponding solution.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Jul 21, 2014 2:18 pm

Hi,

Thanks for that sorry for late reply. That is the code i need many thanks.

stevenheggie
 
Posts: 60
Joined: Tue Jun 24, 2014 10:32 am

Thu Jul 24, 2014 1:51 am

Hello,

Thanks for your feedback.
If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.Doc