I need to be able to insert a document at the end of the current document use classic ASP (vbscript) like so:
Set objWord = CreateObject("Aspose.Words.ComHelper")
Set objDoc = objWord.Open(strWordPath+strFirstPage)
Set builder = CreateObject("Aspose.Words.DocumentBuilder")
builder.Document = objDoc
How do I use InsertDocument at this point to add another document to the one I’ve just referenced?
Hi
Thanks for your request, You can use this code to append one document to another:
' Create a ComeHelper
Dim helper
Set helper = CreateObject("Aspose.Words.ComHelper")
' Open documents
Dim dstDoc
Set dstDoc = helper.Open("dst.doc")
Dim srcDoc
Set srcDoc = helper.Open("src.doc")
'Append source document to destinateion
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("out.doc")
Hope this helps.
Best regards.
Alexey
Perfect. I would not have found the “ImportNode_2” method.
Thanks…
I’d like to take this one step further by saving the image to either a BMP, GIF or JPG. I’m trying this:
Set stream = CreateObject("System.IO.MemoryStream")
objDoc.SaveToImage(0, 1, stream, ImageFormat.Bmp, Nothing)
but I get:
Microsoft VBScript runtime error ‘800a01b6’
Object doesn’t support this property or method: ‘objDoc.SaveToImage’
Is my DLL too old?
Hi
Thanks for your inquiry. I think you should create a wrapper class, which will do all things you need to do with Aspose.Words.
A good approach is to develop a .NET assembly that references Aspose.Words and does all the work with it, and only exposes the minimal set of classes and methods to unmanaged code. Your application then should work just with your wrapper library.
https://reference.aspose.com/words/net/aspose.words/comhelper/open/
I think such approach could simplify you development process.
Best regards.
That looks dandy, but there is no way for me to do that and make the changes on my clients server because I don’t have that type of access to it and I’m sure they don’t use Visual Studio. So I’m stuck in the classic ASP environment using VBScript (which works great) so I just need to figure out how to get this SavetoImage method to work. I think this is last obstacle for my client.
Hi
Thanks for your request. The problem is that, it seems, there is no way to use System.Drawing.Imaging.ImageFormat in COM. So the only way, I managed to save the document as an image is the following:
’ Save to image
doc.SaveToImage 0, 1, “out.bmp”, Nothing
Hope this could help you.
Best regards.
On your advice, I’m trying:
Set objWord = CreateObject("Aspose.Words.ComHelper")
Set objDoc = objWord.Open(strWordPath+strFirstPage)
objDoc.SaveToImage 0, 1, "test.bmp", Nothing
I get the following error:
Object doesn’t support this property or method:
'objDoc.SaveToImage’
This seems to be pretty easy. Any ideas what might be wrong?
Hi
Thanks for your inquiry. Which version of Aspose.Words do you use? SaveToImage and SaveToPdf methods are available starting from Aspose.Words 6.0.0. To check version of the library, right click on the dll, select Properties from the context menu, then select Version tab. You will see File version.
Best regards.