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 / May 2006

Tip: Looking for answers? Try searching our database.

Form Fields has On Exit Macro that goes to a Bookmark

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DeDe - 03 May 2006 07:35 GMT
Hi,

I have a form field that has an On Exit maco that changes the status bar
text then goes to a pre-defined bookmark.

The Status Bar part works OK, however, the cursor doesn't move to the
bookmark.

What am I doing wrong?
P.S. I know very little about VBA code.

Thank you in advance.
Charles Kenyon - 03 May 2006 10:01 GMT
Within a protected form you can't move to a bookmark in a protected section
(except a formfield).
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!

My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Hi,
>
[quoted text clipped - 8 lines]
>
> Thank you in advance.
DeDe - 03 May 2006 10:15 GMT
Hi Charles,

Thank you for your response.  

However, the bookmark is not in a protected section.  It is mid-way down an
unprotected section and the cursor lands at the top of the unproteced section
rather than at the bookmark.

Denise

> Within a protected form you can't move to a bookmark in a protected section
> (except a formfield).
[quoted text clipped - 10 lines]
> >
> > Thank you in advance.
Greg Maxey - 03 May 2006 12:27 GMT
I have a rocket that won't fly to the moon.  Why?

Would you be willing to show us your code? ;-)
DeDe - 04 May 2006 04:43 GMT
Hi Greg,

Hope this clarifys it.  The code is:

Sub Add4StatusBar()
 
   Application.StatusBar = "Type the letter."
       
  ' GoToBookmark named StartLetter

   Selection.GoTo What:=wdGoToBookmark, Name:="StartLetter"
       
End Sub

Thanks in advance
Denise

> I have a rocket that won't fly to the moon.  Why?
>
> Would you be willing to show us your code? ;-)
Charles Kenyon - 04 May 2006 13:10 GMT
I just tried your code in a protected document and it runs fine when run
from the vba editor but when run as an on-exit macro it runs and then the
tab completes and goes to the next formfield. When in the last formfield it
also runs but the tab completes at the beginning of the unprotected section.

You need to either end your unprotected section where you want typing to
begin or put in a wait or timeout into your macro.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!

My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Hi Greg,
>
[quoted text clipped - 16 lines]
>>
>> Would you be willing to show us your code? ;-)
Greg Maxey - 04 May 2006 13:50 GMT
Dee,

Charles explains what is happening.  You can work around it with a
variation of:

Sub Add4StatusBar()
Application.OnTime When:=Now, Name:="ReallyAdd4StatusBar"
End Sub
Sub ReallyAdd4StatusBar()
Application.StatusBar = "Type the letter."
If ActiveDocument.Bookmarks.Exists("StartLetter") Then
 ActiveDocument.Bookmarks("StartLetter").Select
End If
End Sub
DeDe - 05 May 2006 03:00 GMT
Hi Greg,

Thank you for your response. I copied your code into the VBA window saved
and re-tested.  However, I still had no luck.

Denise

> Dee,
>
[quoted text clipped - 10 lines]
> End If
> End Sub
Greg Maxey - 05 May 2006 03:35 GMT
Hmm...it worked for me at work today.  The Application.OnTime introduces a
short delay that should get you past the "Tab" effects.  Try andding a bit
of delay like this:

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Add4StatusBar()
Application.ScreenUpdating = False
Doze 100
End Sub
Sub Add4StatusBarReally()
If ActiveDocument.Bookmarks.Exists("Details") Then
 ActiveDocument.Bookmarks("Details").Select
End If
End Sub
Sub Doze(ByVal lngPeriod As Long)
DoEvents
Sleep lngPeriod
Add4StatusBarReally
End Sub

I didn't test this becasue I didn't take the time to recreate your document.
If it doesn't work I am at a loss.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Hi Greg,
>
[quoted text clipped - 17 lines]
>> End If
>> End Sub
DeDe - 05 May 2006 07:30 GMT
Hi Greg,
Still no luck - will have to let it go.  My thanks to you and Charles for
your attention to this issue.

Kind regards
Denise

> Hmm...it worked for me at work today.  The Application.OnTime introduces a
> short delay that should get you past the "Tab" effects.  Try andding a bit
[quoted text clipped - 41 lines]
> >> End If
> >> End Sub
Greg Maxey - 05 May 2006 13:08 GMT
You can e-mail me your document if you want to and I will have a look.
 
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.