Usage of Aspose.Words with ASP

Hi

I think that you can save the generated document on the server and then redirect user to this document. User will get the message window “open / save”.

Best regards.

Hi,

I am working on an ASP application and in the development environment I had used visual studio 2005 to register the Aspose.Words dll using the following command

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

Now that we have successfully used Aspose.Words dll we are planning to move the application in to the integration environment. However, in the integration we cannot use Visual studio as it is shared environment. My question is whether there is any other way to register the Aspose.Words dll.

Thanks and Regards,
Divya

Hi

Thanks for your request. I think that the .NET framework is installed on server. Then you can run this command from console.

cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
RegAsm.exe "C:\Program Files\Aspose\Aspose.Words\Bin\net2.0\Aspose.Words.dll" /tlb:"C:\AsposeInterop.tlb"

If you want to use RegAsm.exe in a Command Prompt window:

1.In Windows Explorer, right-click My Computer, and then click Properties.

2.In the System Properties dialog box, click the Advanced tab, and then click Environment Variables.

3.In the System variables list, click Path, and then click Edit.

  1. Type the following in the Variable value text box, separated from other directories by a semicolon:
    ;%SystemRoot%\Microsoft.NET\Framework\v1.1.4322 (or v2.0.50727)

Windows searches directories in the order they are found in the Path value. Start a new Command Prompt window and type set to see the modified Path value.

I hope that it will help you.

Best regards.

Hi,

I am currently working with Aspose.cells and I am facing issues with the code.

Please find in the attachment the code along with the error snapshot.

Also, i have used smart markers instead of data markers, as seen in one of the threads.

Please guide.

Thanks and Regards,

Divya Dixit

Hi

Your request is related to another component (Aspose.Cells). Please, post this question in the corresponding forum.
https://forum.aspose.com/c/cells/9

Their technical support will respond to you soon.

Best regards.

Hi,

I am facing problem in replacing the softartisans component word writer into Aspose.Words.

I am attaching hte code snippet.

Please guide me through.

Thanks and Regards,
Divya Dixit

Hi

Thanks for your request. I think that you should use mail merge here. See the following code snippet.

Dim WordTempl
Dim helper
Set helper = CreateObject("Aspose.Words.ComHelper")
Set WordTempl = helper.Open(Server.MapPath("./PrintLabelsTemplate.doc"))
WordTempl.MailMerge.ExecuteADO AddressTable
AddressTable.Close()
Dim stream
Set stream = CreateObject("System.IO.MemoryStream")
WordTempl.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

I hope that it will help you.

Best regards.

Hi Alexey,

Thanks a lot for your help and effort. the code did work.

You have really been of great help.

Thanks Again,

Divya

Hi,

I have to remove the microsoft word dependency and use Aspose.Words.

Please find the attched document which contanis the code snippet for the same.

Please guide me through this.

Thanks and Regards,

Divya Dixit

Hi

Thanks for your request. I think that you can create header document and report document using mail merge as I have written you above. And use the following code to merge these documents.

Dim helper
Set helper = CreateObject("Aspose.Words.ComHelper")
Dim currDoc
Set currDoc = helper.Open("E:\Projects\Aspos.words\Tests\TestTwo\bin\115\_88619\_AjayDeshmukh\site2\doc1.doc")
Dim notaryDoc
Set notaryDoc = helper.Open("E:\Projects\Aspos.words\Tests\TestTwo\bin\115\_88619\_AjayDeshmukh\site2\doc2.doc")
Dim notarySection
If notaryDoc.Sections.Count > 0 Then
Set notarySection = currDoc.ImportNode\_2(notaryDoc.Sections.Item(0), True, 1)
'Set continiouse section break
notarySection.PageSetup.SectionStart = 0
currDoc.AppendChild(notarySection)
End If
'Save document
currDoc.Save "E:\Projects\Aspos.words\Tests\TestTwo\bin\115\_88619\_AjayDeshmukh\site2\out2.doc"

I hope that it will help you.

Best regards.

Hi,

Thanks for your help and time.

I, however, have a doubt in using mailmerge in the following piece of code:

For Each oField In rec.Fields
sHead = sHead & oField.Name & vbTab
Next
Dim sTemp As String
sTemp = rec.GetString(2, -1, vbTab)
sTemp = Mid$(sHead, 1, Len(sHead) - 1) & vbCrLf & sTemp
Set wrdDoc = oApp.Documents.Add
Dim range As Word.range
Set range = wrdDoc.range
range.Text = sTemp
range.ConvertToTable vbTab
wrdDoc.SaveAs (data\_source\_file\_dir & data\_store\_file)

'close it
oApp.ActiveDocument.Close (0)
oApp.Quit
Set oApp = Nothing
Set wrdDoc = Nothing

Dim DestAppTest As Word.Application
Set DestAppTest = New Word.Application

Dim DestTestDoc As Word.Document
Set DestTestDoc = DestAppTest.Documents.Open(template\_location\_filepath)

With DestTestDoc.MailMerge
.OpenDataSource data\_source\_file\_dir & data\_store\_file
.Destination = wdSendToNewDocument
.Execute
End With

Set DestTestDoc = DestAppTest.ActiveDocument
DestTestDoc.SaveAs (report\_file\_dir & report\_file)

DestAppTest.ActiveDocument.Close (0)
DestAppTest.ActiveDocument.Close (0)
DestAppTest.Quit
Set DestAppTest = Nothing
Set DestTestDoc = Nothing

I have highlighted the part in blue where I am facing problem. Could you please go through the snippet and guide me.

Thanks for your support,

Divya Dixit

Hi,

I also require your help on the following code to generate the page numbers:

'==logic to place Page Numbers on each Page of the Report
Dim djSectionCounter As Integer
Dim currentSection As Word.Section

For Each currentSection In wDoc.Sections
currentSection.Footers(wdHeaderFooterPrimary).PageNumbers.RestartNumberingAtSection = False
Call currentSection.Footers(wdHeaderFooterPrimary).PageNumbers.Add(PageNumberAlignment:=wdAlignPageNumberCenter, FirstPage:=True)

Next
end dj / rob

wDoc.Save

Thanks for your support,

Divya Dixit

Hi

You can insert page numbers using the following code.

Dim Builder
Set Builder = CreateObject("Aspose.Words.DocumentBuilder")
Builder.Document = currDoc
Builder.Font.Size = 14
'move to footer primary
Builder.MoveToHeaderFooter 3
builder.Write "Page "
builder.InsertField "PAGE", ""

Also, can you attach your template? It is not quite for me what documents are used here.

Set DestTestDoc = DestAppTest.Documents.Open(template\_location\_filepath)

And here

OpenDataSource data_source_file_dir & data_store_file

Best regards.

Hi,

Plese find the template attached for the below code snippet.

Dim DestAppTest As Word.Application
Set DestAppTest = New Word.Application

Dim DestTestDoc As Word.Document
Set DestTestDoc = DestAppTest.Documents.Open(template\_location\_filepath)

With DestTestDoc.MailMerge
.OpenDataSource data\_source\_file\_dir & data\_store\_file
.Destination = wdSendToNewDocument
.Execute
End With

Set DestTestDoc = DestAppTest.ActiveDocument
DestTestDoc.SaveAs (report\_file\_dir & report\_file)

DestAppTest.ActiveDocument.Close (0)
DestAppTest.ActiveDocument.Close (0)
DestAppTest.Quit
Set DestAppTest = Nothing
Set DestTestDoc = Nothing

Thanks a lot for your help and support,

Divya Dixit

Hi

Thanks for additional information. I think that you should use the following code snippet.

Dim helper
Set helper = CreateObject("Aspose.Words.ComHelper")
Dim Doc
Set Doc = helper.Open(template\_location\_filepath
'Execute MeilMerge
Doc.MailMerge.ExecuteADO rec

rec is your DataSet.

I hope that it will help you.

Best regards.