Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Creating Tables in Word from asp.net

Reply
Thread Tools

Creating Tables in Word from asp.net

 
 
m3ckon
Guest
Posts: n/a
 
      08-03-2004
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      08-03-2004
The easiest way to get the code you need to build the Word table is to
record a macro in Word of you creating a table using the table menu. Then
you can just copy the code from the macro editor into VS .NET.



"m3ckon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
 
m3ckon
Guest
Posts: n/a
 
      08-04-2004

Thanks for the reply

I've managed to progress and create the tables ok, however, ASP.NET
seems to not let go of the winword process at all.

Can someone please tell me how to close this object???

M3ckon


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
m3ckon
Guest
Posts: n/a
 
      08-05-2004

Found out how to get round this....

For the close I used the following statement:

CType(oWordApp, Word._Application).Quit()

(oWordApp is if Type Word.Application)

Hope it Helps

M3ckon


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get database metadata information (i.e. existing tables and columns in tables) Chris Brat Python 5 08-22-2006 05:25 PM
Creating multiple tables for Word.Table using C# nish ASP .Net 1 08-08-2006 02:31 AM
Getting data from tables in a Word document... Stu ASP .Net 1 06-12-2005 07:55 AM
Tables within tables Otuatail HTML 7 08-02-2004 04:42 AM
Text after 2 tables actually appears between 2 tables ! Peter Bassett HTML 3 08-15-2003 06:46 PM



Advertisments