Click to See Complete Forum and Search --> : How to open word doc in Line #5


Lev FatMan
May 9th, 2001, 08:14 AM
How to open word doc in Line #5

FatMAn

Cakkie
May 9th, 2001, 09:01 AM
This code will open Word, open a file and goto line 5

private Sub Command1_Click()

' declare the objects
Dim aWord as Object
Dim oDoc as Object
Dim oRange as Object

' start Word and show it
set aWord = CreateObject("Word.Application")
aWord.Visible = true

' open a document
set oDoc = aWord.Documents.Open("c:\somedocument.doc")

' goto the fifth line
set oRange = oDoc.GoTo(wdGoToLine, wdGoToAbsolute, 5)
oRange.Select

End Sub




Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook