'Word.Bookmarks' does not contain a definition for 'Item'

S

Steven Huypens

Hi,

I recently got my new PC with Windows XP SP2, Office 2003 and VS.NET
2003. My code was working fine on my old Win2k, Office2k, VS.Net
machine, but now I get this error.

"'Word.Bookmarks' does not contain a definition for 'Item'"

Here is the function I'm using :

private void BookMarkReplaceRange(ref Word.Document ThisDocument, string
bookmarkName, string newText)
{
try
{
object missingValue = Type.Missing;
object oBookmarkName = bookmarkName;
Word.Range rng = ThisDocument.Bookmarks.Item(
ref oBookmarkName).Range;
rng.Text = newText;
object oRng = rng;
ThisDocument.Bookmarks.Add(bookmarkName, ref oRng);
}
catch (Exception ex)
{
CGlobals.Logger.WriteLine(LogType.Error, ex);
}
}

Does anyone have an idea what might be the problem ?

grtz,

Steven
 
C

Cindy M -WordMVP-

Hi Steven,
I recently got my new PC with Windows XP SP2, Office 2003 and VS.NET
2003. My code was working fine on my old Win2k, Office2k, VS.Net
machine, but now I get this error.

"'Word.Bookmarks' does not contain a definition for 'Item'"
Are you sure the correct Off2003 PIAs are installed and referenced?
Here is the function I'm using :

private void BookMarkReplaceRange(ref Word.Document ThisDocument, string
bookmarkName, string newText)
{
try
{
object missingValue = Type.Missing;
object oBookmarkName = bookmarkName;
Word.Range rng = ThisDocument.Bookmarks.Item(
ref oBookmarkName).Range;
rng.Text = newText;
object oRng = rng;
ThisDocument.Bookmarks.Add(bookmarkName, ref oRng);
}
catch (Exception ex)
{
CGlobals.Logger.WriteLine(LogType.Error, ex);
}
}

Does anyone have an idea what might be the problem ?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
S

Steven Huypens

Hi Cindy,

Thanks for helping me.

I'm not really sure about the Off2003 PIAs. I only made sure Office2003
was completely installed. Can I check this somewhere ?

I did install the XP PIAs, I'm not sure that was a good idea.

If I want my application to work with Word97, Word2k, Word XP and Word
2003, is this possible with only one executable, of will I have to make
an executable for each Word Version ?

grtz,

Steven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top