Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default goto in Word

Hi
I want to open a word file and go to a specific bookmark in word.
Therefore I wrote the code you see below.

....
Private Sub CommandButton1_Click()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("S:\Folder\File.doc")
wrdDoc.GoTo What:=wdGoToBookmark, Name:="SomeText"
End Sub
....

My problem is that it works as far as it opens the file but it does not
go to the position I told to, or at least it does not scroll there. In
Word-VBA a "scroll = true" option is not given like in Excel-VBA.

Additionally I would like to check whether the file is already open
before opening it again. I could not find out yet how to check whether a
file is already open or not.

Does anyone have some advise.
Thanks Philipp

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default goto in Word

To check if Word is already open, this article might give you an idea:
http://www.mvps.org/word/FAQs/InterD...WordFromXL.htm

To get to your bookmark, you might try
wrdDoc.Bookmarks("SomeText").Range.Select

Steve


"Philipp Schramek" wrote in message
...
Hi
I want to open a word file and go to a specific bookmark in word.
Therefore I wrote the code you see below.

...
Private Sub CommandButton1_Click()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("S:\Folder\File.doc")
wrdDoc.GoTo What:=wdGoToBookmark, Name:="SomeText"
End Sub
...

My problem is that it works as far as it opens the file but it does not
go to the position I told to, or at least it does not scroll there. In
Word-VBA a "scroll = true" option is not given like in Excel-VBA.

Additionally I would like to check whether the file is already open
before opening it again. I could not find out yet how to check whether a
file is already open or not.

Does anyone have some advise.
Thanks Philipp



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
? IF & GOTO ? Karen D Excel Worksheet Functions 17 September 2nd 09 10:58 PM
? IF and GOTO ? Karen D Excel Worksheet Functions 2 September 1st 09 07:57 PM
Goto Tab Ed Davis Excel Discussion (Misc queries) 3 September 4th 08 10:35 PM
Goto specified date Diddy Excel Discussion (Misc queries) 3 August 4th 08 05:25 PM
If.....Then GoTo....... Alec H Excel Discussion (Misc queries) 4 February 22nd 06 02:42 PM


All times are GMT +1. The time now is 12:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"