Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public member 'wdGoToPage' on type 'DocumentClass' not found.

Status
Not open for further replies.

christer99

IS-IT--Management
Dec 3, 2001
247
How do I create a reference to wdGoToPage? What is missing? Why are all program examples with out references and why do I do this in Visual Studio 2003?

I can compile the code (build the application), but when I run it I am getting this error:

Public member 'wdGoToPage' on type 'DocumentClass' not found.

Imports Word = Microsoft.Office.Interop.Word

Public Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

Dim oWord As Word.Application
Dim oDoc3 As Word.Document

oDoc3 = oWord.Documents.Add("J:\VBProposalTemplates\surplus4.dot")
oDoc3.Content.Copy()
Dim activeFile As String

oDoc3.Activate()
Dim rad As Word.Range
oWord.Selection.GoTo(What:=oDoc3.wdGoToPage, Which:=oWord.wdGoToNext, Name:="3")
oWord.ActiveDocument.Bookmarks.Add(Name:="temp1", Range:=oWord.Selection.Range)
oDoc3.Selection.GoTo(What:=oWord.wdGoToPage, Which:=oWord.wdGoToNext, Name:="6")

rad = oWord.ActiveDocument.Range(Start:=oWord.ActiveDocument.Bookmarks("temp1").Range.Start, _
End:=oWord.ActiveDocument.Bookmarks("\page").Range.End)

End sub
 
Replace this:
oDoc3 = oWord.Documents.Add("J:\VBProposalTemplates\surplus4.dot")
By this:
Set oDoc3 = oWord.Documents.Add("J:\VBProposalTemplates\surplus4.dot")
And this:
What:=oDoc3.wdGoToPage, Which:=oWord.wdGoToNext
By this:
What:=wdGoToPage, Which:=wdGoToNext

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Driving me crazy, but:

when I change it to "Set... (Set oDoc3 = oWord.Documents.Add("J:\VBProposalTemplates\surplus4.dot") " MS Visual Studio 2003 automatically removes "Set" from the line. The same if I type, the program automatically removes "set" so I assume Visual Studio 2003 doesn't require it.

Then if I change the "what..." to What:=wdGoToPage, Which:=wdGoToNext

oWord.Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Name:="3")

I am getting this error: Name 'wdGoToPage' is not declared.

and I can't even build the solution

I am also very confused why I have to reference everything when all the program examples are set up like this. Any help would be appreciated. I am ready to throw out the computer out of the window.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top