Log in

View Full Version : Select first field and run entry macro



clhare
06-07-2010, 12:26 PM
I have a template that contains several formfields, some of which use an entry macro which runs a calendar form for date selection.

I'm finding that if the very first field in the document is supposed to run the entry macro, the entry macro isn't run for that field. If I tab, I go to the second field and run it's entry macro. The only way to get the entry macro to run on the first field is to tab to one of the other fields, then tab back to the first field.

How do I get the macros to select the first field (so the user can see which field they are on), then get the entry macro to run for that field, then replace the value of that field based on the value in the calendar form?

I hope my description makes sense!
Thanks!

fumei
06-07-2010, 01:33 PM
Your description is fine. The issue is that when you protect for forms the point of Selection is defaulted to being IN the first formfield. Thus it is already "entered". It is already there. So the OnEntry will not fire.

The only possible solution (other than doing exactly what you mention going forward, then backwards) is to put a formfield BEFORE your "first" formfield, and make it very very small (font size = 1).

So, the document opens up, the Selection defaults to the real first formfield (but so small you can't even see it). Unfortunately that means the user must press Tab to go to the "first" (but actually second) formfield,which will then fire its OnEntry.

I am not sure what you mean by: "How do I get the macros to select the first field (so the user can see which field they are on"

What macro? The OnEntry macros do not (normally) select a field. And the user selects the formfield (by Tab usually), and it is selected, so they can see it. I do not understand about the macros doing something "so the user can see which field they are on". They can see it already.

clhare
06-07-2010, 03:15 PM
Sorry, I meant get the first field to be selected so the user could tell where they were in the document. I went with your idea of making a new "first" field that is very tiny. Better to have to tab and get to what they think is the first field (and get the entry macro to fire) than not. This works just fine now!

Thanks!

clhare
06-08-2010, 04:01 AM
Just wondering... is there a way to program in a "tab" when the document is locked and get to the first real field for the user?

Tinbendr
06-08-2010, 09:48 AM
SendKeys "{TAB}"

You could also select the Last formfield in the document on startup, send a tab, then the selection will be on the first field.

This way, you won't need a extra field.

ActiveDocument.FormFields(ActiveDocument.FormFields.Count).Select
SendKeys ("TAB")

fumei
06-08-2010, 09:52 AM
Nice one Tinbendr.

clhare
06-08-2010, 02:09 PM
Perfect! Thanks! This works great!

sarahjoe
11-19-2014, 12:52 AM
I would like to force the paste icon in Word 2007 to default to “unformatted text”; also acceptable would be a single right mouse click option. I found the code to add Paste Special to the right click menu, but then the user must select from a menu.
I need your help to make this user proof.

gmayor
11-19-2014, 03:55 AM
You would have been better starting a new thread than adding to a four year old one that has no relevance to your question. However you can set the default paste options in Word 2007 from Office Button > Word Options > Advanced.