Usage of Aspose.Words with ASP

Hi Vladimir,

I could successfully generate certain reports for my application.

However, there are certain reports that fail to generate in the fashion they are ought to. I am attaching an excel sheet with the issues that i am facing. Please go through the same. I am also attaching to you the code snippet for every issue. I have my best to explain, if still in any case you face any difficulty please revert. Please guide.

Thanks and Regards,

Divya

Hi Vladimir,

This is in case you have not got my excel sheet in the attachment.

Regards,
Divya

Hi

  1. Document should duplicate itself if DataRecord contains multiple rows (It is normal). You can try to return all data in one row and then execute mailmerge.

  2. Please attach document with problem.

  3. Are you sure that this recordset is not empty?

  4. It is not clear for me what do you want to do. You can convert system date to string and use DocumentBuilder.Write method.

Best regards.

Hi,

One of my queries was to populate the date merge field with System Date.

I am attaching you the document along with my piece of code please go through the same and let me know if I am missing out on something.

Thanks and regards,
Divya

Hi,

Please find the document attached here in.

Regards,

Divya

Hi

Thanks for your request and the additional information. You can use only ExecuteADO method in classic ASP. That’s why I think that you should use the following code.

Dim strDate 
strDate = FormatDateTime(Date(), vbShortDate)
Dim helper
Set helper = CreateObject("Aspose.Words.ComHelper")
Dim Doc
Set Doc = helper.Open("E:\Projects\Aspos.words\Tests\TestTwo\bin\115\_88619\_AjayDeshmukh\site2\Date.doc")
'Create new RecordSet
Dim rsParam
Set rsParam = CreateObject("ADODB.Recordset")
rsParam.Fields.Append "Date", CInt(129), CInt(40), False
rsParam.Open
'Fill RecordSet 
rsParam.AddNew Array("Date"), Array(strDate)
'Execute MeilMerge
Doc.MailMerge.ExecuteADO rsParam
'Save document
doc.Save "E:\Projects\Aspos.words\Tests\TestTwo\bin\115\_88619\_AjayDeshmukh\site2\out.doc"
rsParam.Close()

I hope that it will help you.

Thanks a ton Vitaly. It worked.

As I was going through Aspose documentation, can’t I use ExecuteArray for populating the documents in ASP?

Many thanks again,

Divya

Hi

No, you can’t use ExecuteArray for populating the documents in ASP. You can use ExecuteADO only in ASP.

Best regards.

Hi Vitaly,

Greetings to you!

As you had helped in populating the system date, there was a line in the piece of code as

rsParam.Fields.Append "Date", CInt(129), CInt(40), False

I want to ask you that in case i am using recordset that gives me output as Varchar then what can be the possible solution. I tried out a couple of examples but could not work out any :slight_smile:

Please suggest.

Thanks a lot for your help,

Divya

Hi

Sorry, but it is not clear for me what you want to do.

best regards.

Hi Vitaly,

I am attaching the code that I am trying to use. Also please find below the code the snap shot of the error that I am facing.

Thanks and Regards,

Divya

Hi.

Thanks for additional information. I think that I have found the problem. You can’t use this code:

rsParam1.AddNew Array("ConventionName"), Array(convention\_name)
rsParam1.AddNew Array("ConventionCity"), Array(city\_name)
rsParam1.AddNew Array("SpecialInstructions"), 1
rsParam1.AddNew Array("ConventionManagerName"), Array(full\_name)
rsParam1.AddNew Array("ConventionManagerTitle"), Array(Title)
rsParam1.AddNew Array("ConventionManagerPhone"), Array(PHONE\_NUMBER)

You should use the following:

rsParam.AddNew Array("ConventionName", "ConventionCity", "SpecialInstructions", "ConventionManagerName", "ConventionManagerTitle", "ConventionManagerPhone"), Array(convention\_name,city\_name, Special,full\_name, Title, PHONE\_NUMBER)

Also see the attachment.

Best regards.

Hi,

Thanks for your help, I could successfully populate the reports. However, there is a glitch. When I try to integrate the reports together in the application, I get the error Response object error ‘ASP 0106 : 80020005’ , it throws me error on line 0 which as per my investigation occurs due to complex data types more commonly array, and I have used array in populating my reports as suggested. My reports work fine individually but when integrated with the application result in the stated error.

I am trying to resolve the error from my side and if you can provide me with any kind of guidance it would really help me out in resolving the error. Your kind support is appreciated and thanks a lot for your efforts in helping me with the usage of Aspose.

In case you require any further clarifications please do let me know.

Thanks and Regards,

Divya

Hi

Thanks for your request. Do you get this exception when try to insert the data from your web form to your document? Please provide me some code that will allow me to reproduce your proble. I will try to help you.

Best regards.

Hi Vitaly,

Thanks for your support. However, i could solve the problem. Now i am facing another one :slight_smile:

As i could not attach the document, i am pasting the code snippet where i am facing the problem along with the error… Please help me out in this one.

The code snippet is:

'Fill the Record set

rsParamaFFWN.AddNew Array("ConventionName", "ExpectedAttendance", \_
"ConventionCity", "ArrivalDate", "ArrivalTime", "DepartureTime", "DepartureDate", \_
"ExhibitStartDate", "ExhibitEndDate", "Date", "TravelAgentNumber", \_
"ConventionManagerName", "ConventionManagerAddress", "ConventionManagerTitle", \_
"ConventionManagerPhone", "HousingManagerName", "HousingManagerPhone", \_
"WorkHotelData", "AwardHotelData", "OtherHotelData", "EventInfo", \_
"RecipientName", "FacilityName", "FacilityAddress", "FacilityCity", "FacilityState", \_
"FacilityZip", "ExhibitInfo", "Attendance", "ExhibitHours", "ParticipantList", \_
"SpecialInstruction"), \_
Array(convention\_name, expected\_attendance, city\_name, arrival\_date, arrival\_time, \_
departure\_time, departure\_date, exhibit\_start\_date, exhibit\_end\_date, \_
strDate, travel\_agent\_number, full\_name, \_
GetManagerAddress(rsConventionManagerInfo), TITLE, Phone\_Number, full\_name, \_
Phone\_Number, WorkHotel\_str, AwardHotel\_str, OtherHotel\_str, \_
GetOrientationEventDinners(rcEventInfo), \_
CMS\_Recipients(CurrentRecipient).RecipientName, facility\_name, Address, CITY, \_
STATE, ZIP, strBooth, expected\_attendance, strExhibit, \_
GetParticipantsWorkList(rsParticipantsObj, False), \_
Special\_Instructions)

And the error that i am facing is:

Multiple-step operation generated errors. Check each status value.

Thanks a lot for you Support and Help,

Divya

Hi Vitaly,

I am sorry for wasting your time. I could recognize the error and I have solved it. Sorry, again for creating a fracus unnecessary :slight_smile:

I however, need your help in using the If Else condition with Aspose. Though it sounds very simple, i have actually wasted one day in trying to understand however, in vain.

Please find my code snippet below:

In this code, i am trying to populate the values from the database. However, at certain points there may not be any value or it may be null. For Example, if some one has not entered their phone number in the database (as phone number is not a mandatory field) then it should not populate that particular area in the document. However, it was throwing me error “Invalid Null”. As a result i used the if else condition to check the null values. Please find the code below:

If rsConventionHousingInfo.Fields("PHONE\_NUMBER").value = Null Or rsConventionHousingInfo.Fields("PHONE\_NUMBER").value = "NULL" Then
Phone\_Number = " "
objStream.WriteLine Phone\_Number
Else
Phone\_Number = rsConventionHousingInfo.Fields("PHONE\_NUMBER").value
End If

Now this code works fine if i comment the else part (the one highlighted in blue). However, it doesn’t work if i uncomment that part, which should not be the case.

Please guide me for this. I really thank you for your support and patience ofcourse :slight_smile:

Thanks and Regards,
Divya

Hi

Thanks for your request. You can try to rewrite your condition. See the following code.

Phone\_Number = " "

If rsConventionHousingInfo.Fields("PHONE\_NUMBER").value <> Null Or rsConventionHousingInfo.Fields("PHONE\_NUMBER").value <> "NULL" Then
Phone\_Number = rsConventionHousingInfo.Fields("PHONE\_NUMBER").value

End If

Best regards

Hi

Thanks so much for your help and support. I have one more issue, that i would like to discuss with you. Basically in my application, there is not going to be any GUI. that is the user will click on the button Preview Letter (a button that is present in my application) and the letter will be displayed with the values populated to him. I think i will explain you the flow as

Button Preview Letter -> Letter is displayed with Values populated.

Now, what is happening in the current scenario is that the letter is getting saved as temporary letter in the application’s folder structure, which is not a feasible thing from buisness point of view as it may lead to issues with the users.

So what i did was used the following code for generating the letter on the button click.

If bln_html = True Then

docaFFWN.Save strLetter , True

Else
docaFFWN.Save strLetter, False
End If

however this code gives me error as Wrong number of arguments passed.

However, when i use only docFFWN.Save strLetter the letter gets saved as a temporary letter in the temporary letter location under the folder structure of my applicaiton.

I have tried my best to explain you the problem faced, still in case you have issues understanding i will try myself to be more lucid and vivid.

Thanks again,

Divya

Hi

Some methods have overloads and they will be exposed to COM clients with a number suffix added to them except the very first method that stays unchanged. For example, Document.Save method overloads become Document.Save, Document.Save_2, Document.Save_3, and so on. The order in which method overloads are shown in the API documentation corresponds to the way they are numbered. This is the approach that .NET COM Interop takes to make overloaded methods available to COM clients.

Best regards.

Hi

As suggested by you i refered the code on the link https://docs.aspose.com/words/net/supported-platforms/#com

Under the heading:

This example demonstrates how to use Aspose.Words from a classical ASP page to dynamically generate a document.

However, the issue is that the COM+ component used in the applicaiton is in VB and in VB we cannot use Response.

Please suggest me another alternative.

Thanks and Regards,

Divya