Macro usage issues

N

nelson ang

Hello

I created a protected document that has Editing Restrictions. I made exceptions for users to update 3 Text Form Field namely the Version No,Date and Document ID.

I have also created a macro button that will update all fields. These the issues i am facing.

1) i need to click the macro button before the macro works,the run macro on exit/calculate does not work(in both protected/unprotected).


The codes are as followed.

Sub updatefields()
Dim oStory As Range
Dim oField As Field
For Each oStory In ActiveDocument.StoryRanges
For Each oField In oStory.Fields
oField.Update
Next oField
Next oStory

End Sub


EggHeadCafe - Software Developer Portal of Choice
SQL Server Estimating Compression Savings
http://www.eggheadcafe.com/tutorial...3-ff0c0ea346fd/sql-server-estimating-com.aspx
 
G

Graham Mayor

Which Word version?
What *exactly* are you trying to achieve?
Which fields is the macro supposed to update?
Form fields only work when the document is protected.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
N

nelson ang

i am using word2007 and hope to create a protected document whereby users can change values in the text form field in the 1st page. Then,the header/footer of subsequent pages will take the value of the text form field.

currently i made 3 text form field namely
1)Version No
2)Date
3)Document ID

i am hoping to make use of the macro to auto update the text form fields value into the headers/footers in subsequent pages.

I have managed to protect the document and create a macro button that updates all fields in the header/footer based on the text form fields value in the first page.

What i am lacking is to make the header/footer AUTO update the value when the user make any changes in any of the 3 text form fields.

I tried 'run macro on exit' but it does not work for me



Graham Mayor wrote:

Which Word version?What *exactly* are you trying to achieve?
23-Nov-09

Which Word version
What *exactly* are you trying to achieve
Which fields is the macro supposed to update
Form fields only work when the document is protected

-
<>>< ><<> ><<> <>>< ><<> <>>< <>><<
Graham Mayor - Word MV

My web site www.gmayor.co
Word MVP web site http://word.mvps.or
<>>< ><<> ><<> <>>< ><<> <>>< <>><<

nelson ang wrote:

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
Notify Client Applications Using WCF Callbacks
http://www.eggheadcafe.com/tutorial...8-457b3a4f137c/notify-client-application.aspx
 
N

nelson ang

i am using word2007 and hope to create a protected document whereby users can change values in the text form field in the 1st page. Then,the header/footer of subsequent pages will take the value of the text form field.

currently i made 3 text form field namely
1)Version No
2)Date
3)Document ID

i am hoping to make use of the macro to auto update the text form fields value into the headers/footers in subsequent pages.

I have managed to protect the document and create a macro button that updates all fields in the header/footer based on the text form fields value in the first page.

What i am lacking is to make the header/footer AUTO update the value when the user make any changes in any of the 3 text form fields.

I tried 'run macro on exit' but it does not work for me



Graham Mayor wrote:

Which Word version?What *exactly* are you trying to achieve?
23-Nov-09

Which Word version
What *exactly* are you trying to achieve
Which fields is the macro supposed to update
Form fields only work when the document is protected

-
<>>< ><<> ><<> <>>< ><<> <>>< <>><<
Graham Mayor - Word MV

My web site www.gmayor.co
Word MVP web site http://word.mvps.or
<>>< ><<> ><<> <>>< ><<> <>>< <>><<

nelson ang wrote:

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
..NET Disaster Recovery, Safe Computer and Spyware
http://www.eggheadcafe.com/tutorial...beb-6e8c5bdbb848/net-disaster-recovery-s.aspx
 
G

Graham Mayor

OK REF fields in the header/footer do not update automatically and do not
update when triggered by the calculate on exit check box. They will update
if you use a macro on exit from the field to update them, but your problem
is then to persuade other users to allow the macros stored in the document
to run. Over that you have no control.

If there are only three fields involved, the simple solution is to create
three character styles FF1 FF2 and FF3 and apply them to the three fields.
The styles merely provide nbames that can be used by Styleref fields.
Styleref fields in the header will update automatically without macros.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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