PDA

View Full Version : Bookmarks problem



ukemike
08-31-2005, 08:08 AM
Hey guys,
I have a question.
I am opening a new document which has a bookmark "bmShape". This bookmark is used for inserting an image (AddPicture()). I doing a find/replace on some fields then I erase all the bookmarks in this file, insert a new section, insert another copy of this file (InsertFile()) at the start of the new section. So this new copy of the document has the "bmShape" bookmark, and the old one (first copy) should NOT have this bookmark since I deleted all the bookmarks for it, but for some reason when i go to this bookmark programmatically its still going to the bookmarks that should have been deleted on the first copy of this document.
This is all C# code so thats why i didnt post any code.
Could this be some kind of refresh issue where after deleting all the bookmarks they are still somehow in memory.

Any help greatly appreciated.

Mike

MOS MASTER
08-31-2005, 03:38 PM
Hi Mike, :yes

Which version of Office are you working with?

And could you attach your C# code in a text file? Perhaps I cannot read it in whole but you must use VBA in it that I can read and perhaps it's just something I can discover out of it?

Cause for now I don't see a reasonable explanation yet for this phantom bookmark. :whistle:

ukemike
09-02-2005, 09:08 AM
Hello,
MOS, The C# Class is aroud 1300 lines. Plus my code is really hard to read. Let me ask you think:
I talked to someone and they said that Word has a refresh bookmark feature/function. Is this true? What would the name of this function in VBA?


Mike

MOS MASTER
09-02-2005, 10:24 AM
Hello,
I talked to someone and they said that Word has a refresh bookmark feature/function. Is this true? What would the name of this function in VBA?


Hi Mike, :yes

Well that someone knows more then me or I don't understand what he's saying.

I'm not aware of a autorefresh function of the bookmark collection. It does have a exists function to determine if a bookmark exists but a refresh one.....

:whistle:

fumei
09-06-2005, 08:54 AM
. This bookmark is used for inserting an image (AddPicture()).

Could you describe this function in more detail?

Also, there is no refresh of the bookmarks collection.


Plus my code is really hard to read.
Then it is poor code.


I doing a find/replace on some fields then I erase all the bookmarks in this file, insert a new section, insert another copy of this file (InsertFile()) at the start of the new section.

Could you please at least post the code that "erases" all the bookmarks? Clearly, you are not in fact doing that, are you. If the bookmark is still there....well then, your code does NOT erase all bookmarks. You may think it is doing that....but if the bookmark is still then - well, then you are incorrect. Your code is not erasing all the bookmarks. The only way to remove all bookmatrks is something like:
Dim var
For var = ActiveDocument.Bookmarks.Count To 1 Step -1
ActiveDocument.Bookmarks(var).Delete
Next

The other questions - WHY are you doing this deletion? Why are you bringing in the same document? Since you did not state so, I am assuming the TEXT of the original document remains, and you are bringing in the same text?

What version are you using (always a helpful piece of information)? How are you inserting the same file? Word generally does not allow the same file to be inserted into itself.

Perhaps a few more details would help.