Usage of Aspose.Words with ASP

Received : 2007/07/31 00:42:01
Message : Hi Vladimir,

Thanks for the documentation. I have read this. But the main problem that I am encountering is in registration of Aspose.Words dll with my application.
My application is in ASP. I have used the following command to register it.

Regasm "C:\Program Files\Aspose\Aspose.Words\Bin\net2.0\Aspose.Words.dll" /tlb:"C:\AsposeInterop.tlb" 

I registered it using visual studio .Net command prompt and I get “successfully registered the dll”, also. I am able to add the Aspose.Words dll under references section also. However, when I try to run my application I get the error “ActiveX component can’t create object”. So I guess there is some problem with the dll registration itself, or any thing else? Can you please guide.

Regards,
Divya

This message was posted using Aspose.Live 2 Forum

Try to closely follow the installation guidelines stated in Utilize Aspose.Words from COM Clients (ASP, VB, VBScript) article. If it does not help please attach the code of your ASP application so that we could reproduce the problem on our side.

Best regards,

Especially make sure that you follow this point:

You must chose the Everyone option in the Select Installation Folder dialog box as shown below. If you do not do this, Aspose.Words will be COM registered for the current user and ASP application running under a different account will fail to instantiate Aspose.Words classes.

Hi Vladimir,

Sorry for starting a new thread every time. I will take care for the same. The code snippet was:

Dim helper 
Set helper = CreateObject("Aspose.Words.Document") 
Dim doc 
Set doc = helper.Open("C:\\myDoc.doc") 

The error occurs at the blue line. The error is Run-time automation error: The system could not find the specified file. As suggested by you I gave the necessary permissions and even used the local path, however, the error persists.

As per my analysis the automation error occurs when the dll is not loaded properly. I unregistered the dll and tried loading it again. I was successfully able to view the Aspose dlls through regedit. I could successfully see Aspose.Words.ComHelper, Aspose.Words.Documents, Aspose.Words.DocumentBuilder, Aspose.Words.License and Aspose.Words.Viewer.DocumentRenderer.

I could also successfully open the tlb file through the COM object viewer. And in the installation procedure I had selected the Everyone option in the Select Installation Folder dialog box.

Thanks a lot for your support,

Regards,
Divya

I see an error in your code. You see, COM in ASP does not allow parametrized constructors. That’s why you can only use CreateObject("Aspose.Words.Document) to create a new document. And to load the document the existing file you need to use ComHelper object

Dim helper

*'You try to Aspose.Words.Document
'but you should create Aspose.Words.ComHelper instead
Set helper = CreateObject(“Aspose.Words.ComHelper”)

Dim doc
Set doc = helper.Open(fileName)*

Hope this helps,

Hi Vladimir,

As suggested by you I just now tried using the ComHelper instead of Document

But still I am getting the same error.

Regards,

Divya

Hi Vladimir,

Just to add on one more observation from my side. When I view the type library in COM Object viewer under library Aspose_Words I find:

importlib("mscorlib.tlb");
importlib("stdole2.tlb");

I tried to include mscorlib.tlb as Common Language Runtime Library under references.

But could not refer stdole2.tlb

Could this be the possible reason for the error?

Regards,

Divya

Sorry, I am not much of a specialist in COM. I am only sure that the following example works on my side:

Dim helper
Set helper = CreateObject(“Aspose.Words.ComHelper”)

Dim doc
Set doc = helper.Open(“c:\inetpub\wwwroot\dir1\test.doc”)

That is if my ASP page is in the same directory as the document file (c:\inetpub\wwwroot\dir1).

So to help you further I need to be able to reproduce your error. Try composing a complete test set and attach it here with instructions so that I could run it on my side and reproduce the problem. That seem to be the only way to find the cause of the problem.

Best regards,

Hi Vladimir,

Could the error arise due the dll not being registered in the GAC?

I registered the Aspose.Words.dll in to the GAC using the gacutil command.

However when I tried to use the regasm command in order to register the dll an error was thrown.

I did the following:

Gacutil /i "C:\Program Files\Aspose\Aspose.Words\Bin\net1.1\Aspose.Words.dll"
Regasm "C:\WINNT\assembly\Aspose.Words.dll"

this command gave me error unable to locate the input assemblies or one of its dependencies.

I tried searching for this error and got one more command /codebase. But even that did not work and threw the same error.

Regards,
Divya

No, there I absolutely no need to register Aspose components in GAC. In fact, we do not recommend doing it.

Hi Valdimir,

I just tried out by adding the Aspose.Words.dll in GAC using the gacutil command.

It was successful and I was able to execute the code snippet without error.

I have another doubt regarding SetDataSource method. While I was going through Google search I found that in thread

there was mention about SetDataSource method for Aspose.Cells. Can I use the SetDataSource method in Aspose.Words? I am asking this because I am working on ASP application and although the methods may be available they are visible only at run-time (Guess this is because ASP is a late bound language!).

The problem is that if I use SetDataSource in my code, it gives me error: Object doesn’t support this property or method.

Regards,

Divya

You can use API reference keeping in mind the guidelines described in “Usage” section of the article:
https://docs.aspose.com/words/net/supported-platforms/#com
to find out what methods are supported and what parameters are accepted for these methods.

If you will check the API Reference you will find out that there is no such method as SetDataSource in our API.

Best regards,

Hi Vladimir,

I am trying to populate fields in the document using Aspose.Words.

For this I have referred to the SalesInvoiceDemo, as it uses the merge field in the document and I have similar kind of case. In this usage of MailMerge.ExceuteWithRegions property is seen.

When I try to use this property in my ASP application I get the error Object doesn’t support this property or method.

Please guide as to what can be done in this regards. I am also attaching the code in case needed please refer the same.

Many thanks,

Divya

Hi

A similar issue was discusse

Best regards.

Hi ,

When i click the link

I get Access Denied: Post permission denied error (Either this forum doesnot exists or you are not allowed to post)

Regards,

Divya

Hi

Sorry, it is my mistake, this thead is private.

You can use only ExecuteADO method in classic ASP. See the following link.
https://reference.aspose.com/words/net/aspose.words.mailmerging/mailmerge/methods/executeado

In order to get your data not from datasource you can create empty Recordset and add data from your page into it.

Best regards.

Hi,

As suggested by you I referred the given code.

However, I have one more doubt. The document is saved at the location but the merge fields are empty. I mean they are not populated. I have attached the code, please go through the same and let me know if I am missing out something.

In the code you will find that I have used array to capture the values from the database (using the function getDataFromDB).

Please guide me.

Many Regards,
Divya

Your code does not look like the code for populating dataset

Try to follow this code closely and also try to simplify your example. Create a simple merge document with only one merge field and try to merge it with a similarly simple recordset.

Hi,

I could successfully populate the merge fields for one of my reports. However, when i tried to do this separately for another report, although i didn’t get an error however my document showed me section break (next page).

I have used the same code as posted yesterday. It worked successfully for one report. However, I am not able to figure out why it is not working for another report I am trying to populate.

Please guide.

Thanks and Regards,

Divya

I need to be able to reproduce this problem on my side to come up with some advice.