Using Aspose.Word with VB6

I found the following code on your site regarding using Aspose products with a COM product like VB6.

Dim Word as Object
Set Word = CreateObject("Aspose.Word.Word")

Dim Document as Object
Set Document = Word.Open("MyInputFileName.doc")

Document.Save("MyOutputFileName.doc")

The code errors on the line:

Set Word = CreateObject("Aspose.Word.Word")

with the follwoing message:
File or assembly name Aspose.Word, or one of its dependencies, was not found.

Any ideas?

Hi

Thanks for your inquiry. Please see the following link to learn how to use Aspose.Words via COM.

Hope this helps.

Best regards

OK. I noticed that my code was missing the s in aspose.words.word. I had aspose.word.word. Now the following line of code:

Set aWord = CreateObject("Aspose.Words.word")

causes the following error:
ActiveX component can't create object

Hi

Thanks for your request. Aspose.Word is old namespace. Currently we are using Aspose.Words.

There is no Aspose.Words.Word class. Please see documentation for more information.

I suppose you are trying to run old code with the latest version of product. Have you tried to run code provided in the article I suggested in my previous post?

Best regards.

As I stated I changed my code to add the s and am getting the error (see previous post)

Hi

Thanks for your inquiry. Please try using the following code:

'Create a document
Dim Doc
Doc = CreateObject("Aspose.Words.Document")

'Create a DocumentBuilder
Dim Builder
Builder = CreateObject("Aspose.Words.DocumentBuilder")

Builder.Document = Doc
Builder.Font.Size = 48

'ParagraphAlignment.Center = 1
Builder.ParagraphFormat.Alignment = 1
Builder.Writeln("Hello, World!")

'Create a .NET memory stream to save the document to.
Dim stream
stream = CreateObject("System.IO.MemoryStream")

'Save the document to the stream.
'We use an overloaded version of the Save method: Document.Save(object, SaveFormat)
'SaveFormat.Doc = 1
doc.Save_4(stream, 1)

Response.Clear()

'Specify the document type.
Response.ContentType = "application/msword"
'Other options:
'Response.ContentType = "text/plain"
'Response.ContentType = "text/html"

'Specify how the document is sent to the browser.
Response.AddHeader("content-disposition", "attachment; filename=MyDocument.doc")
'Another option could be:
'Response.AddHeader "content-disposition","inline; filename=MyDocument.doc";

'Get data bytes from the stream and send it to the response.
Dim bytes
bytes = stream.ToArray()
Response.BinaryWrite(bytes)
Response.End()

Also please provide me your code.

Best regards.

I have tried your code and still get the error. The code I was trying is included in the 1st post I sent. As I stated previously the error occurs on the line where I attempt to create the object:

Doc = CreateObject("Aspose.Words.Document")

This is the same line of code as in my original post where the error occurs. The error is:

Run-time error '429': ActiveX component can't create object.

Hi

Thanks for your inquiry. Maybe you should also register Aspose.Words assembly for COM. It is possible to register Aspose.Words for COM Interop manually by executing the following command:

[.NET Framework 1.1]

regasm "C:\Program Files\Aspose\Aspose.Words\bin\net1.1\Aspose.Words.DLL" /codebase

[.NET Framework 2.0, 3.0 or 3.5]

regasm "C:\Program Files\Aspose\Aspose.Words\bin\net2.0\Aspose.Words.DLL" /codebase

regasm.exe is a tool included in .NET Framework SDK. All the .NET Framework SDK tools are located in the \Microsoft .NET\Framevork\ directory, e.g. C:\Windows\Microsoft .NET\Framework\v1.1.4322. If you use Visual Studio .NET, it is handy to select 'Start | Programs | Microsoft Visual Studio .NET 2003 | Visual Studio .NET Tools | Visual Studio .NET 2003 Command Prompt. It will run command prompt with all the necessary environment variables set.

Hope this helps.

Best regards.