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

Tip: Looking for answers? Try searching our database.

Auto fill and macros in a protected form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AllYourSpam - 03 Aug 2006 22:24 GMT
I have read through all similar postings, but none quite fit.

I'm trying to set up an order form with a "bill-to" and "ship-to" that may
or may not be the same. I have a few questions:

1) How do I use a check box labeled "Same" and have all the bill-to fields
(name, address, city, state, etc) auto fill in the ship-to fields. Sometimes
the bill-to and ship-to are not the same so I need to be able to track both
sets of data.

2) How do I track all data (whether the fields are changed or not)? Does the
solution to question 1 "overwrite" the fields if the data is the same?

3) I have set up my own macro, but in order for the form to work, it need to
be protected, and then if the form is protected, my macro errors, telling me
to unprotect the document. How do I get that to function properly?

Thanks in advance
Greg Maxey - 03 Aug 2006 22:43 GMT
Say the billing name field was named "BName" and the shipping name field is
named "SName."  You could run an on exit macro from the checkbox named
"Same."

Change "SomeOtherField to the field name that you want to skip to if the
same box is checked.

Sub OnExitSame()
Dim oFlds As FormFields
Set oFlds = ActiveDocument.FormFields
If oFlds("Same").CheckBox.Value = True Then
 oFlds("SName").Result = oFlds("BName").Result
 'Add other similiar field pairs here
 oFlds("SomeOtherField").Select
 Selection.Range.Fields(1).Result.Select
End If
End Sub

Signature

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

> I have read through all similar postings, but none quite fit.
>
[quoted text clipped - 16 lines]
>
> Thanks in advance
AllYourSpam - 04 Aug 2006 15:49 GMT
Thanks for your help so far, but it is not working properly. I have only
recorded macros before, never written the code, so I probably did something
wrong.

Here is what happens: The macro attempts to work, but it removes the data
from the bill-to fields, leaving them blank, and then does not write any data
to the ship-to fields, so I end up with all the fields blank. Then I get a
run-time error 5941 "the requested member of the collection does not exist"
when it tries to advance to the next field for manual entry again.

I have double checked the field names and they are all correct, so I'm not
sure what the problem is. Either way, that wouldn't answer the disappearing
data problem.

Here is my code. The last field should advance to a radio button - is that a
problem?

Sub OnExitSame()
Dim oFlds As FormFields
Set oFlds = ActiveDocument.FormFields
If oFlds("Same").CheckBox.Value = True Then
 oFlds("ShopName").Result = oFlds("ShipTo").Result
 oFlds("First").Result = oFlds("ShipToFirst").Result
 oFlds("Middle").Result = oFlds("ShipToMiddle").Result
 oFlds("Last").Result = oFlds("ShipToLast").Result
 oFlds("HomeNo").Result = oFlds("ShipToHomeNo").Result
 oFlds("WorkNo").Result = oFlds("ShipToWorkNo").Result
 oFlds("CellNo").Result = oFlds("ShipToCellNo").Result
 oFlds("Address").Result = oFlds("ShipToAddress").Result
 oFlds("City").Result = oFlds("ShipToCity").Result
 oFlds("State").Result = oFlds("ShipToState").Result
 oFlds("Zip").Result = oFlds("ShipToZip").Result
 oFlds("LiftGateYes").Select
 Selection.Range.Fields(1).Result.Select
' Same Macro
' Macro recorded 8/4/2006 by CAC
End If
End Sub

Thanks so much, your help is greatly appreciated.
CAC

> Say the billing name field was named "BName" and the shipping name field is
> named "SName."  You could run an on exit macro from the checkbox named
[quoted text clipped - 34 lines]
> >
> > Thanks in advance
Greg Maxey - 04 Aug 2006 20:53 GMT
E-mail me your document.  You should be able to cipher out the spam proofing
in my address.

Signature

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

> Thanks for your help so far, but it is not working properly. I have only
> recorded macros before, never written the code, so I probably did
[quoted text clipped - 82 lines]
>> >
>> > Thanks in advance
AllYourSpam - 07 Aug 2006 20:02 GMT
See my e-mail with the same subject line. let me know if you don't get it.
Thanks CAC

> E-mail me your document.  You should be able to cipher out the spam proofing
> in my address.
[quoted text clipped - 85 lines]
> >> >
> >> > Thanks in advance
Greg Maxey - 07 Aug 2006 21:20 GMT
As of 1620 today I didn't get it.  The last three letters of the
address is org

> See my e-mail with the same subject line. let me know if you don't get it.
> Thanks CAC
[quoted text clipped - 100 lines]
> > >> >
> > >> > Thanks in advance
AllYourSpam - 08 Aug 2006 17:22 GMT
Yeah, I did get the .org part, but I will send the e-mail again. Thanks

> As of 1620 today I didn't get it.  The last three letters of the
> address is org
[quoted text clipped - 103 lines]
> > > >> >
> > > >> > Thanks in advance
AllYourSpam - 11 Aug 2006 15:56 GMT
To anyone that is interested, Greg did help me with a solution. He is
Phenomenal!
Thanks Greg,

CAC

> Yeah, I did get the .org part, but I will send the e-mail again. Thanks
>
[quoted text clipped - 105 lines]
> > > > >> >
> > > > >> > Thanks in advance

Rate this thread:






 
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.