I’m adding aspose.words to an old ASP system and need help with adding sections from one document to another. I’ve setup the COM conection and i’m able to open a document and write to it. But now I need to be able to load in additional documents and combine them with others to output one document.
The code in asp.net to add doc to outputDoc would be:
Dim sourceSection As Section = doc.Sections(0)
Dim NewSection As Section = CType(outputDoc.ImportNode(sourceSection, True), Section)
outputDoc.Sections.Add(NewSection)
What would the equivilent code be to acomplish the same task in ASP class VB?
Thanks for any help
Hi
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your request. Please try using code like the following:
'Create comhelper
Dim comHelper
Set comHelper = CreateObject("Aspose.Words.ComHelper")
'open destination and source documents
Dim dstDoc
Set dstDoc = comHelper.Open(Server.MapPath("dst.doc"))
Dim srcDoc
Set srcDoc = comHelper.Open(Server.MapPath("src.doc"))
'Append source document to destination
Dim dstSection
Dim i
For i=0 To srcDoc.Sections.Count - 1
Set dstSection = dstDoc.ImportNode_2(srcDoc.Sections.Item(i), True, 1 )
dstDoc.AppendChild( dstSection )
Next
'Save output document
dstDoc.Save(Server.MapPath("out.doc"))
Hope this helps.
Best regards.