Can't close footer

V

Vivian Carroll

In Word 2002 I have a macrobutton in the footer of the document that is
intended to delete the paragraph containing the macro button, return to the
main document, and then run another macro. Below is the entire code. When I
"step" through it, the footer closes as expected, but when I double-click
it, the paragraph with the macro button is deleted as desired, but the
cursor stays in the footer. What can I do to make the footer close?

With Selection
.MoveRight Unit:=wdCharacter, Count:=1
.Expand Unit:=wdParagraph
.Delete
End With

ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Application.Run MacroName:="Find_Next_Caret"

TIA, Vivian
 
V

Vivian Carroll

I just played some more. If I put the same macro on a toolbar button, it
works fine. Is there something I don't know about macrobuttons not working
right in footers - or some extra step you have to take if you put a
macrobutton in a footer?
 
C

Cindy Meister -WordMVP-

Hi Vivian,

I've never tried running a macrobutton from a footer, so I'm not sure...

1) To delete the paragraph containing the button, I'd probably use:
Selection.Range.Paragraphs(1).Delete

2) You might try sticking a DoEvents in after the deletion, to give Word
"time to catch up".

3) It might also have something to do with the fact that you're deleting the
macrobutton that's running the macro! So you might try something like this
(off the top of my head):

dim rng as Word.Range

Set rng = Selection.Range.Paragraphs(1).Range
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Application.Run MacroName:="Find_Next_Caret"
rng.Delete

IOW, do everythign else and only delete the macro button at the end.
In Word 2002 I have a macrobutton in the footer of the document that is
intended to delete the paragraph containing the macro button, return to the
main document, and then run another macro. Below is the entire code. When I
"step" through it, the footer closes as expected, but when I double-click
it, the paragraph with the macro button is deleted as desired, but the
cursor stays in the footer. What can I do to make the footer close?

With Selection
.MoveRight Unit:=wdCharacter, Count:=1
.Expand Unit:=wdParagraph
.Delete
End With

ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Application.Run MacroName:="Find_Next_Caret"

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

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

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