Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Finding Bookmark in Header

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Angie M. - 21 Feb 2007 22:53 GMT
Hello,

I have the following macro that should delete a graphic in a header that  I
have marked with a bookmark:

Sub NoELtr()

   Selection.HomeKey Unit:=wdStory

   ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
 
   ActiveDocument.Bookmarks("bkltrLogo").Range.Delete

   Selection.ParagraphFormat.SpaceAfter = 42
   
   ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
   Selection.MoveDown Unit:=wdLine, Count:=3

End Sub

I get an error that says it doesn't find it - could it be because it's in
the header, but I open the header.  This can be done manually of course.  Any
suggestions are appreciated.
Jezebel - 22 Feb 2007 08:37 GMT
The fact that it's in the header is irrelevant. And you don't need all that
selection and window stuff either. If the bookmark really exists (and you
haven't miss-spelled the name), then

 ActiveDocument.Bookmarks("bkltrLogo").Range.Delete

is all you need. If Word is saying the bookmark doesn't exist, then it
doesn't exist (check the Insert > Bookmark dialog).

> Hello,
>
[quoted text clipped - 21 lines]
> Any
> suggestions are appreciated.
Jean-Guy Marcil - 22 Feb 2007 15:33 GMT
Jezebel was telling us:
Jezebel nous racontait que :

> The fact that it's in the header is irrelevant. And you don't need
> all that selection and window stuff either. If the bookmark really
[quoted text clipped - 4 lines]
> is all you need. If Word is saying the bookmark doesn't exist, then it
> doesn't exist (check the Insert > Bookmark dialog).

Also, because the OP is doing something in the header after deleting the
logo, she would need something like:

'_______________________________________
Sub NoELtr()

Dim rgeHeader As Range

Set rgeHeader = ActiveDocument.Bookmarks("bkltrLogo").Range

With rgeHeader
   .Delete
   .ParagraphFormat.SpaceAfter = 42
End With

End Sub
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Angie M. - 22 Feb 2007 19:45 GMT
HELP!  this still doesn't work.  I also tested it in a new blank doc with a
graphic not in the header, I selected the graphic, insert bookmark, and added
the bookmark and tried this code and also the
"ActiveDocument.Bookmarks("bkltrLogo").Range.Delete".  The macro lived in a
global template but I put the macro in the actual letterhead template where
I'm trying to run the macro.  I've checked the bookmark name and even deleted
and restablished it.  

My real problem is that I have a graphic line in the header that I don't
want deleted otherwise it would be easy to just delete the paragraph mark
where the graphic was anchored and I wouldn't have to mess with a bookmark at
all.  Any other suggestions?  Thanks a lot

> Jezebel was telling us:
> Jezebel nous racontait que :
[quoted text clipped - 25 lines]
> End Sub
> '_______________________________________
Jezebel - 22 Feb 2007 21:14 GMT
Take a deep breath and explain, from the top, what you are trying to do,
without making reference to your own (clearly unsuccessful) attempted
method.

> HELP!  this still doesn't work.  I also tested it in a new blank doc with
> a
[quoted text clipped - 44 lines]
>> End Sub
>> '_______________________________________
Angie M. - 22 Feb 2007 21:52 GMT
I have a letterhead template that contains a logo graphic, a graphic line
below the logo and a table that contains personalized information (I have one
letterhead template for each person due to all of the personal preferences).  
These items reside in the first page header.  I need a macro that will delete
the logo but not the graphic line or the table, and I need a macro that will
insert the logo (this macro works fine).  I have two versions of each
template, one with the logo and one without.  If they start with a non-logo
template they want to be able to add a logo, if they start with the logo they
want to be able to remove it.  

The big problem I'm having is that I cannot delete the logo without deleting
the line.

Yes I would have originally created one template for each person with a logo
and no logo choice on the dialog, but at this point I don't have that choice.

I've also tried to add the line to the table and jack things around but it's
a huge amount of work for the workaround when all I need to do is delete the
graphic.  

Thanks for your help

> Take a deep breath and explain, from the top, what you are trying to do,
> without making reference to your own (clearly unsuccessful) attempted
[quoted text clipped - 48 lines]
> >> End Sub
> >> '_______________________________________
Jezebel - 22 Feb 2007 22:31 GMT
OK, that clarifies. If the logo and line are separate graphics, the current
problem is possibly that what you've bookmarked is not the logo but the
paragraph to which it is anchored, and the line is anchored to that
paragraph also. Thus deleting the bookmark removes both graphics.

Try deleting the graphic directly, using something like --

Activedocument.Sections(1).Headers(wdHeaderFooterFirstPage).Shapes(1).Delete

>I have a letterhead template that contains a logo graphic, a graphic line
> below the logo and a table that contains personalized information (I have
[quoted text clipped - 88 lines]
>> >> End Sub
>> >> '_______________________________________
Angie M. - 26 Feb 2007 03:18 GMT
THANK YOU JEZEBEL.  I had to change it to shape 2 but IT WORKED.  Thanks for
your time, I really appreciate it.  I had selected the shape and added the
bookmark, I don't know why that didn't work but I don't care at this point,
just glad something worked.

> OK, that clarifies. If the logo and line are separate graphics, the current
> problem is possibly that what you've bookmarked is not the logo but the
[quoted text clipped - 97 lines]
> >> >> End Sub
> >> >> '_______________________________________
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.