Below is the code that I am using to CREATE an instance of WORD, if none exists…then OPEN the specified document…then GoTo the specified page.
The code is activated from the ‘click’ event of a Command Button that is inserted into a Visio drawing.
The purpose of the Command Button is to allow the User to immediately view the Step-by-Step procedures associated with the Work Flows on the respective drawing.
The code for the Command Button <cmdImpResTer> works great…when activated it takes the User to the specified WORD document…and OPENS that document up at PAGE 37.
The problem that I have is that I have approximately 60 drawings that each need to have an associated Command Button that will perform exactly the same…with the only difference being possibly a different DOCUMENT and different PAGE number.
Each time I try to use the code with another Command Button…see <cmdNotRevTer>…it OPENS the document just fine at Page 1…but I cannot get the GoToPage to activate like it does in the code I created for <cmdImpResTer>.
When I StepInto the successful code…wdGoToPage =1
When I StepInto any succession of the same code for another button…wdGoToPage = Empty
Here is my successful code:
Private Sub cmdImpResTer_Click()
‘
Set Wd = Nothing
‘
Set Wd = CreateObject(“Word.Application”)
Wd.Visible = True
‘
For Each doc In Wd.Documents
If doc.Name = “OSO1000_TtMngPro.doc” Then Found = True
Next doc
If Found <> True Then
Wd.Documents.Open “C:\Documentation\OSO1000_TtMngPro.doc”
Wd.Selection.GoTo What:=wdGoToPage, Count:=”37”
Else
Wd.Selection.GoTo What:=wdGoToPage, Count:=”37”
End If
End Sub
Here is my unsuccessful code (only Opens the document…but does not GoTo specified Page):
Private Sub cmdNotRevTer_Click()
‘
Set Wd = Nothing
‘
Set Wd = CreateObject(“Word.Application”)
Wd.Visible = True
‘
For Each doc In Wd.Documents
If doc.Name = “OSO1000_TtMngPro.doc” Then Found = True
Next doc
If Found <> True Then
Wd.Documents.Open “C:\Documentation\OSO1000_TtMngPro.doc”
Wd.Selection.GoTo What:=wdGoToPage, Count:=”35”
Else
Wd.Selection.GoTo What:=wdGoToPage, Count:=”35”
End If
End Sub
The code is activated from the ‘click’ event of a Command Button that is inserted into a Visio drawing.
The purpose of the Command Button is to allow the User to immediately view the Step-by-Step procedures associated with the Work Flows on the respective drawing.
The code for the Command Button <cmdImpResTer> works great…when activated it takes the User to the specified WORD document…and OPENS that document up at PAGE 37.
The problem that I have is that I have approximately 60 drawings that each need to have an associated Command Button that will perform exactly the same…with the only difference being possibly a different DOCUMENT and different PAGE number.
Each time I try to use the code with another Command Button…see <cmdNotRevTer>…it OPENS the document just fine at Page 1…but I cannot get the GoToPage to activate like it does in the code I created for <cmdImpResTer>.
When I StepInto the successful code…wdGoToPage =1
When I StepInto any succession of the same code for another button…wdGoToPage = Empty
Here is my successful code:
Private Sub cmdImpResTer_Click()
‘
Set Wd = Nothing
‘
Set Wd = CreateObject(“Word.Application”)
Wd.Visible = True
‘
For Each doc In Wd.Documents
If doc.Name = “OSO1000_TtMngPro.doc” Then Found = True
Next doc
If Found <> True Then
Wd.Documents.Open “C:\Documentation\OSO1000_TtMngPro.doc”
Wd.Selection.GoTo What:=wdGoToPage, Count:=”37”
Else
Wd.Selection.GoTo What:=wdGoToPage, Count:=”37”
End If
End Sub
Here is my unsuccessful code (only Opens the document…but does not GoTo specified Page):
Private Sub cmdNotRevTer_Click()
‘
Set Wd = Nothing
‘
Set Wd = CreateObject(“Word.Application”)
Wd.Visible = True
‘
For Each doc In Wd.Documents
If doc.Name = “OSO1000_TtMngPro.doc” Then Found = True
Next doc
If Found <> True Then
Wd.Documents.Open “C:\Documentation\OSO1000_TtMngPro.doc”
Wd.Selection.GoTo What:=wdGoToPage, Count:=”35”
Else
Wd.Selection.GoTo What:=wdGoToPage, Count:=”35”
End If
End Sub