Click to See Complete Forum and Search --> : Opening Word Documents


jesse_mac07
September 7th, 2004, 10:33 AM
In my program, I am wanting to open a word document and place the cursor at a predefined bookmark inside of the word document. In code, how would I open the document and go to the bookmark? Thanks a lot.

soumya_bhatta
September 7th, 2004, 06:11 PM
Opening Word Documents:
Add reference through the COM reference to Microsoft Word 9.0 COM reference library(or whatever is the latest)

'Create a variable that represents the Application class

Dim myWordApp As New Word.Application
'Then assuming you already have a saved doc file in your folder Your word file.doc

doc1=myWordApp.Documents.Open("Your word file.doc")

Now microsoft word provides numerous objects that you can use to program any action that can be done by the word menu command.

I do not know how to go to a bookmark by using word with .Net. However, if I am stuck, I would have done this:

*Record a macro and see what VB code is getting registered for going to a bookmark by the menu
*Try to simulate that code in vb.Net

jesse_mac07
September 8th, 2004, 10:11 AM
Thanks a bunch!

jwoody
March 11th, 2005, 10:35 AM
Can AnyOne Tell me how to fill a Microsoft Word textBox from VB.Net ??

I found I can Create One Like This. But I Can't seem to fill it with text . .


Dim oWord As New Word.Application
Dim oDoc As Word._Document
oWord.Visible = True
oDoc = oWord.Documents.Open( _
FileName:="C:\ascentia\docjobsum1.doc", _
ConfirmConversions:=False, _
ReadOnly:=True, _
AddToRecentFiles:=False, _
Format:=Word.WdOpenFormat.wdOpenFormatAuto)

With oDoc.Shapes
.AddTextbox (Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 10, 10, 100, 10)

End With

jwoody
March 12th, 2005, 01:13 PM
the answer turned out to be

oDoc.Shapes.Item("Text Box 1").Select()
oWord.Selection.TypeText(Text:="Some text")