M
m3ckon
Hi there,
I can succesfully create a word doc from my asp.net page, but I have 2
issues I need to resolve in order to use it in my app:
1) Creating a table: I seem unable to create a table, I'm uing the coe
below, but I'm unsure as to what the Range parameter should be for
oWordDoc.Content.Tables.Add ???
2) ASP.net does not seem to let go of the winword process, hence locking
my document...how can I resolve this??
Code Listing:
Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document
Dim oPara1 As Word.Paragraph
Dim oRng As Word.Range
Dim oTable1 As Word.Table
oWordApp = CreateObject("word.application")
oWordApp.Visible = True
oWordDoc = oWordApp.Documents.Add
oPara1 = oWordDoc.Content.Paragraphs.Add
oPara1.Style = "Heading 1"
oPara1.Range.Text = "Text on the page"
oPara1.Range.InsertParagraphAfter()
Dim r, c As Integer
oTable1 = oWordDoc.Content.Tables.Add(???range??help???, 2, 3)
For r = 1 To 2
For c = 1 To 3
oTable1.Cell(r, c).Range.Text = "r" & r & "c" & c
Next
Next
oTable1.Range.InsertParagraphAfter()
oWordDoc.SaveAs("c:\\test3.doc")
oWordDoc.Quit()
Regards,
M3ckon
I can succesfully create a word doc from my asp.net page, but I have 2
issues I need to resolve in order to use it in my app:
1) Creating a table: I seem unable to create a table, I'm uing the coe
below, but I'm unsure as to what the Range parameter should be for
oWordDoc.Content.Tables.Add ???
2) ASP.net does not seem to let go of the winword process, hence locking
my document...how can I resolve this??
Code Listing:
Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document
Dim oPara1 As Word.Paragraph
Dim oRng As Word.Range
Dim oTable1 As Word.Table
oWordApp = CreateObject("word.application")
oWordApp.Visible = True
oWordDoc = oWordApp.Documents.Add
oPara1 = oWordDoc.Content.Paragraphs.Add
oPara1.Style = "Heading 1"
oPara1.Range.Text = "Text on the page"
oPara1.Range.InsertParagraphAfter()
Dim r, c As Integer
oTable1 = oWordDoc.Content.Tables.Add(???range??help???, 2, 3)
For r = 1 To 2
For c = 1 To 3
oTable1.Cell(r, c).Range.Text = "r" & r & "c" & c
Next
Next
oTable1.Range.InsertParagraphAfter()
oWordDoc.SaveAs("c:\\test3.doc")
oWordDoc.Quit()
Regards,
M3ckon