PC Review


Reply
Thread Tools Rate Thread

Word automation with vb.net

 
 
William LaMartin
Guest
Posts: n/a
 
      30th Jul 2004
I had no trouble doing this sort of thing in VBA. What I want to do is open
a Word document, change the values of its fields that are of DOCVariable
type save the changes and exit. But in VB.net I can not figure out the code
to change the values of the fields.

The code below, cycles through all of the fields in the document displaying
the field type and what the current text is.

How do I change the value of the fields?

'need references to Office and word object libraries
Dim oWordApp As New Microsoft.Office.Interop.Word.Application
oWordApp.Visible = True
Dim docPath As String = Application.StartupPath & "\Test2.doc"
oWordApp.Documents.Open(docPath)
Dim i As Integer
For i = 1 To oWordApp.ActiveDocument.Fields.Count - 1
MsgBox("Type: " &
oWordApp.ActiveDocument.Fields.Item(i).Type.ToString)
MsgBox("Result.Text: " &
oWordApp.ActiveDocument.Fields.Item(i).Result.Text())
Next
oWordApp.Quit()


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Supressing the ctrl-c and other keys during word automation in automation apondu Microsoft VB .NET 1 23rd Jul 2007 10:45 PM
Supressing the ctrl-c and other keys during word automation in automation apondu Microsoft C# .NET 0 19th Jul 2007 10:15 PM
Supressing the ctrl-c and other keys during word automation in automation apondu Microsoft Word Document Management 0 19th Jul 2007 10:15 PM
Supressing the ctrl-c and other keys during word automation in automation apondu Microsoft ASP .NET 0 19th Jul 2007 10:10 PM
Supressing the ctrl-c and other keys during word automation in automation apondu Microsoft Excel Programming 0 19th Jul 2007 10:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:12 PM.