M
Mindy
I want to write some code to go to a specific place in a
long WOrd document. The document continues to grow as the
code runs, so "m_intCurrentNumPages" is the current number
of pages. I use "m_intCurrentNumPages - 1" so that the
range will be the next to last page (ie, I just want to
look at the last two pages of the document)
Dim oRange As Word.Range
Dim oSelection As Word.Selection
oSelection.GoTo(What:=Word.WdGoToItem.wdGoToPage, _
Which:=(m_intCurrentNumPages - 1))
oRange.Start = oSelection.Start
oRange.End = oDoc.Content.End
oRange.Select()
On the oSelection.GoTo line, an error occurs: "Object
reference not set to an instance of an object."
I cannot do "Dim oSelection As NEW Word.Selection"... The
New keyword creates a compile error ("new cannot be used
on an interface"), so I am not sure where my object
reference is not set.
On this line of code, I am trying to tell it to go to a
specific page. Do I have the "Which" value set wrong? Does
it have to be a wd Word constant? If so, how do I
specify, "go to page 14"
I am VB.NET and am automating a Word document object.
long WOrd document. The document continues to grow as the
code runs, so "m_intCurrentNumPages" is the current number
of pages. I use "m_intCurrentNumPages - 1" so that the
range will be the next to last page (ie, I just want to
look at the last two pages of the document)
Dim oRange As Word.Range
Dim oSelection As Word.Selection
oSelection.GoTo(What:=Word.WdGoToItem.wdGoToPage, _
Which:=(m_intCurrentNumPages - 1))
oRange.Start = oSelection.Start
oRange.End = oDoc.Content.End
oRange.Select()
On the oSelection.GoTo line, an error occurs: "Object
reference not set to an instance of an object."
I cannot do "Dim oSelection As NEW Word.Selection"... The
New keyword creates a compile error ("new cannot be used
on an interface"), so I am not sure where my object
reference is not set.
On this line of code, I am trying to tell it to go to a
specific page. Do I have the "Which" value set wrong? Does
it have to be a wd Word constant? If so, how do I
specify, "go to page 14"
I am VB.NET and am automating a Word document object.