|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Would appreciate some help on the below. I have a document that has several fields in it that I would like to fill using a userform. I have created the userform, and the document with fields.
Now I need a way to update the fields in the document with the text in the userform. Basically I guess I need the code to put under the commandbutton that would do this action... Can someone help me on this ? Am really lost .... Not a big VBscripter I am afraid...
Thanks !
Marc
|
|
To avoid misconceptions:
I prefer to do this thru a userform that auto-opens, looks like the best method. Only thing I can find however is ways to use this with bookmarks... I want to do it thru docproperty fields,looks nicer I guess... Any help is appreciated.. This must have been done earlier... ?
"Marc Jurriens" <helmonder[ at ]hotmail.com> wrote in message news:Oe9yBmNzGHA.4844[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text] > Would appreciate some help on the below. I have a document that has > several fields in it that I would like to fill using a userform. I have > created the userform, and the document with fields. > > Now I need a way to update the fields in the document with the text in the > userform. Basically I guess I need the code to put under the commandbutton > that would do this action... Can someone help me on this ? Am really lost > ... Not a big VBscripter I am afraid... > > Thanks ! > > Marc >
|
|
Marc Jurriens was telling us: Marc Jurriens nous racontait que :
[Quoted Text] > To avoid misconceptions: > > I prefer to do this thru a userform that auto-opens, looks like the
Ok, do you need help with this as well? IS there a question in there?
> best method. Only thing I can find however is ways to use this with > bookmarks... I want to do it thru docproperty fields,looks nicer I
With bookmarks, the code behind the command button would look like:
With Me Activedocument.Bookmarks("Bookmark1_Name").Range.Text = .TextBox1.Text Activedocument.Bookmarks("Bookmark2_Name").Range.Text = .TextBox2.Text 'etc. End with
How do DocProperty fields look nicer? Once the info is in the document and printed, it all looks the same, no? Or are you planning on re-using the same document with different info (by re-launching the userform), so you want to keep the fields in place?
In this case, once you have created the custom properties and placed the DocProperty fields in the documents, you need code like:
With Me ActiveDocument.CustomDocumentProperties("DocProp_1").Value = ..TextBox1.Text ActiveDocument.CustomDocumentProperties("DocProp_2").Value = ..TextBox2.Text 'etc. ActiveDocument.Fields.Update End with
> guess... Any help is appreciated.. This must have been done > earlier... ?
-- Salut! _______________________________________ Jean-Guy Marcil - Word MVP jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO Word MVP site: http://www.word.mvps.org
|
|
Hiya.
[Quoted Text] > How do DocProperty fields look nicer? Once the info is in the document and > printed, it all looks the same, no? Or are you planning on re-using the > same document with different info (by re-launching the userform), so you > want to keep the fields in place?
That is exactly the issue. I want to be able to reuse the form and make adjustments... With bookmarks and REF fields I cannot get this to work.
> In this case, once you have created the custom properties and placed the > DocProperty fields in the documents, you need code like: > > With Me > ActiveDocument.CustomDocumentProperties("DocProp_1").Value = > .TextBox1.Text > ActiveDocument.CustomDocumentProperties("DocProp_2").Value = > .TextBox2.Text > 'etc. > ActiveDocument.Fields.Update > End with
So this is the answer ? I just put in the document fields and add this code to the form ? I'll try out right away !!
Marc
"Jean-Guy Marcil" <NoSpam[ at ]LeaveMeAlone> wrote in message news:%23J2togQzGHA.4092[ at ]TK2MSFTNGP04.phx.gbl... > Marc Jurriens was telling us: > Marc Jurriens nous racontait que : > >> To avoid misconceptions: >> >> I prefer to do this thru a userform that auto-opens, looks like the > > Ok, do you need help with this as well? IS there a question in there? > >> best method. Only thing I can find however is ways to use this with >> bookmarks... I want to do it thru docproperty fields,looks nicer I > > With bookmarks, the code behind the command button would look like: > > With Me > Activedocument.Bookmarks("Bookmark1_Name").Range.Text = .TextBox1.Text > Activedocument.Bookmarks("Bookmark2_Name").Range.Text = .TextBox2.Text > 'etc. > End with > > How do DocProperty fields look nicer? Once the info is in the document and > printed, it all looks the same, no? Or are you planning on re-using the > same document with different info (by re-launching the userform), so you > want to keep the fields in place? > > In this case, once you have created the custom properties and placed the > DocProperty fields in the documents, you need code like: > > With Me > ActiveDocument.CustomDocumentProperties("DocProp_1").Value = > .TextBox1.Text > ActiveDocument.CustomDocumentProperties("DocProp_2").Value = > .TextBox2.Text > 'etc. > ActiveDocument.Fields.Update > End with > >> guess... Any help is appreciated.. This must have been done >> earlier... ? > > > > -- > Salut! > _______________________________________ > Jean-Guy Marcil - Word MVP > jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO > Word MVP site: http://www.word.mvps.org >
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_000B_01C6CDBA.551BBC50 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
LS,
Thanks this works now 90%.
Two puzzling things are still remaining:
1) After I have completed the form the fields in the document did not = auto-update, I need to do an update all fields manually.. I added code = to update all fields after the userform gets closed, this however does = not seem to work, the total code now looks like this:
Private Sub CommandButton1_Click() Unload UserForm1
With Me ActiveDocument.CustomDocumentProperties("CUSTOMER").Value =3D = CUSTOMER ActiveDocument.CustomDocumentProperties("C_SHORT").Value =3D C_SHORT ActiveDocument.CustomDocumentProperties("INITIALS").Value =3D = INITIALS ActiveDocument.CustomDocumentProperties("OWNER").Value =3D OWNER ActiveDocument.CustomDocumentProperties("MANTEL").Value =3D MANTEL ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value =3D = OPENINGHOURS ActiveDocument.CustomDocumentProperties("DURATION").Value =3D = DURATION ActiveDocument.CustomDocumentProperties("VERSION").Value =3D VERSION ActiveDocument.CustomDocumentProperties("STATUS").Value =3D STATUS ActiveDocument.Fields.Update End With
End Sub
Sub UpdateAll() 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
What am I doing wrong ?
The other thing I notice is that the fields in the userform allways have = the -initial- items in the fields pre-loaded instead of the latest = status of the fields. Anyone any idea how I can fix that ?
Thanks!
Marc
"Marc Jurriens" <helmonder[ at ]hotmail.com> wrote in message = news:%23JPuw7ZzGHA.4176[ at ]TK2MSFTNGP06.phx.gbl...
[Quoted Text] > Hiya. >=20 >> How do DocProperty fields look nicer? Once the info is in the =
document and=20 >> printed, it all looks the same, no? Or are you planning on re-using = the=20 >> same document with different info (by re-launching the userform), so = you=20 >> want to keep the fields in place? >=20 > That is exactly the issue. I want to be able to reuse the form and = make=20 > adjustments... With bookmarks and REF fields I cannot get this to = work. >=20 >> In this case, once you have created the custom properties and placed = the=20 >> DocProperty fields in the documents, you need code like: >> >> With Me >> ActiveDocument.CustomDocumentProperties("DocProp_1").Value =3D=20 >> .TextBox1.Text >> ActiveDocument.CustomDocumentProperties("DocProp_2").Value =3D=20 >> .TextBox2.Text >> 'etc. >> ActiveDocument.Fields.Update >> End with >=20 > So this is the answer ? I just put in the document fields and add = this code=20 > to the form ? I'll try out right away !! >=20 > Marc >=20 >=20 >=20 >=20 > "Jean-Guy Marcil" <NoSpam[ at ]LeaveMeAlone> wrote in message=20 > news:%23J2togQzGHA.4092[ at ]TK2MSFTNGP04.phx.gbl... >> Marc Jurriens was telling us: >> Marc Jurriens nous racontait que : >> >>> To avoid misconceptions: >>> >>> I prefer to do this thru a userform that auto-opens, looks like the >> >> Ok, do you need help with this as well? IS there a question in there? >> >>> best method. Only thing I can find however is ways to use this with >>> bookmarks... I want to do it thru docproperty fields,looks nicer I >> >> With bookmarks, the code behind the command button would look like: >> >> With Me >> Activedocument.Bookmarks("Bookmark1_Name").Range.Text =3D = ..TextBox1.Text >> Activedocument.Bookmarks("Bookmark2_Name").Range.Text =3D = ..TextBox2.Text >> 'etc. >> End with >> >> How do DocProperty fields look nicer? Once the info is in the = document and=20 >> printed, it all looks the same, no? Or are you planning on re-using = the=20 >> same document with different info (by re-launching the userform), so = you=20 >> want to keep the fields in place? >> >> In this case, once you have created the custom properties and placed = the=20 >> DocProperty fields in the documents, you need code like: >> >> With Me >> ActiveDocument.CustomDocumentProperties("DocProp_1").Value =3D=20 >> .TextBox1.Text >> ActiveDocument.CustomDocumentProperties("DocProp_2").Value =3D=20 >> .TextBox2.Text >> 'etc. >> ActiveDocument.Fields.Update >> End with >> >>> guess... Any help is appreciated.. This must have been done >>> earlier... ? >> >> >> >> --=20 >> Salut! >> _______________________________________ >> Jean-Guy Marcil - Word MVP >> jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO >> Word MVP site: http://www.word.mvps.org >>=20 >=20 > ------=_NextPart_000_000B_01C6CDBA.551BBC50 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2900.2963" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY> <DIV><FONT face=3DArial size=3D2>LS,</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Thanks this works now 90%.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Two puzzling things are still=20 remaining:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>1) After I have completed the form the = fields in=20 the document did not auto-update, I need to do an update all fields = manually.. I=20 added code to update all fields after the userform gets closed, this = however=20 does not seem to work, the total code now looks like = this:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Private Sub=20 CommandButton1_Click()<BR>Unload UserForm1</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>With = Me<BR> =20 ActiveDocument.CustomDocumentProperties("CUSTOMER").Value =3D=20 CUSTOMER<BR> =20 ActiveDocument.CustomDocumentProperties("C_SHORT").Value =3D=20 C_SHORT<BR> =20 ActiveDocument.CustomDocumentProperties("INITIALS").Value =3D=20 INITIALS<BR> =20 ActiveDocument.CustomDocumentProperties("OWNER").Value =3D=20 OWNER<BR> =20 ActiveDocument.CustomDocumentProperties("MANTEL").Value =3D=20 MANTEL<BR> =20 ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value =3D=20 OPENINGHOURS<BR> =20 ActiveDocument.CustomDocumentProperties("DURATION").Value =3D=20 DURATION<BR> =20 ActiveDocument.CustomDocumentProperties("VERSION").Value =3D=20 VERSION<BR> =20 ActiveDocument.CustomDocumentProperties("STATUS").Value =3D=20 STATUS<BR> ActiveDocument.Fields.Update<BR>End=20 With</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>End Sub</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Sub UpdateAll()<BR>Dim = oStory As=20 Range<BR>Dim oField As Field<BR> For Each oStory In=20 ActiveDocument.StoryRanges<BR> For Each oField In=20 oStory.Fields<BR> =20 oField.Update<BR> Next oField<BR> Next = oStory<BR>End=20 Sub<BR></FONT></DIV> <DIV><FONT face=3DArial size=3D2>What am I doing wrong ?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>The other thing I notice is that the = fields in the=20 userform allways have the -initial- items in the fields pre-loaded = instead of=20 the latest status of the fields. Anyone any idea how I can fix that=20 ?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Thanks!</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Marc</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>"Marc Jurriens" <</FONT><A=20 href=3D"mailto:helmonder[ at ]hotmail.com"><FONT face=3DArial=20 size=3D2>helmonder[ at ]hotmail.com</FONT></A><FONT face=3DArial = size=3D2>> wrote in=20 message </FONT><A = href=3D"news:%23JPuw7ZzGHA.4176[ at ]TK2MSFTNGP06.phx.gbl"><FONT=20 face=3DArial = size=3D2>news:%23JPuw7ZzGHA.4176[ at ]TK2MSFTNGP06.phx.gbl</FONT></A><FONT=20 face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>> = Hiya.<BR>>=20 <BR>>> How do DocProperty fields look nicer? Once the info is in = the=20 document and <BR>>> printed, it all looks the same, no? Or are you =
planning on re-using the <BR>>> same document with different info = (by=20 re-launching the userform), so you <BR>>> want to keep the fields = in=20 place?<BR>> <BR>> That is exactly the issue. I want to be able to = reuse=20 the form and make <BR>> adjustments... With bookmarks and REF fields = I cannot=20 get this to work.<BR>> <BR>>> In this case, once you have = created the=20 custom properties and placed the <BR>>> DocProperty fields in the=20 documents, you need code like:<BR>>><BR>>> With=20 Me<BR>>> =20 ActiveDocument.CustomDocumentProperties("DocProp_1").Value =3D = <BR>>>=20 ..TextBox1.Text<BR>>> =20 ActiveDocument.CustomDocumentProperties("DocProp_2").Value =3D = <BR>>>=20 ..TextBox2.Text<BR>>> = 'etc.<BR>>> =20 ActiveDocument.Fields.Update<BR>>> End with<BR>> <BR>> So = this is=20 the answer ? I just put in the document fields and add this code = <BR>>=20 to the form ? I'll try out right away !!<BR>> <BR>> = Marc<BR>>=20 <BR>> <BR>> <BR>> <BR>> "Jean-Guy Marcil" <</FONT><A=20 href=3D"mailto:NoSpam[ at ]LeaveMeAlone"><FONT face=3DArial=20 size=3D2>NoSpam[ at ]LeaveMeAlone</FONT></A><FONT face=3DArial size=3D2>> = wrote in=20 message <BR>> </FONT><A=20 href=3D"news:%23J2togQzGHA.4092[ at ]TK2MSFTNGP04.phx.gbl"><FONT face=3DArial =
size=3D2>news:%23J2togQzGHA.4092[ at ]TK2MSFTNGP04.phx.gbl</FONT></A><FONT = face=3DArial=20 size=3D2>...<BR>>> Marc Jurriens was telling us:<BR>>> Marc = Jurriens=20 nous racontait que :<BR>>><BR>>>> To avoid=20 misconceptions:<BR>>>><BR>>>> I prefer to do this thru = a=20 userform that auto-opens, looks like the<BR>>><BR>>> Ok, do = you need=20 help with this as well? IS there a question in=20 there?<BR>>><BR>>>> best method. Only thing I can find = however is=20 ways to use this with<BR>>>> bookmarks... I want to do it thru=20 docproperty fields,looks nicer I<BR>>><BR>>> With bookmarks, = the=20 code behind the command button would look like:<BR>>><BR>>> = With=20 Me<BR>>> =20 Activedocument.Bookmarks("Bookmark1_Name").Range.Text =3D=20 ..TextBox1.Text<BR>>> =20 Activedocument.Bookmarks("Bookmark2_Name").Range.Text =3D=20 ..TextBox2.Text<BR>>> 'etc.<BR>>> End=20 with<BR>>><BR>>> How do DocProperty fields look nicer? Once = the info=20 is in the document and <BR>>> printed, it all looks the same, no? = Or are=20 you planning on re-using the <BR>>> same document with different = info (by=20 re-launching the userform), so you <BR>>> want to keep the fields = in=20 place?<BR>>><BR>>> In this case, once you have created the = custom=20 properties and placed the <BR>>> DocProperty fields in the = documents, you=20 need code like:<BR>>><BR>>> With = Me<BR>>> =20 ActiveDocument.CustomDocumentProperties("DocProp_1").Value =3D = <BR>>>=20 ..TextBox1.Text<BR>>> =20 ActiveDocument.CustomDocumentProperties("DocProp_2").Value =3D = <BR>>>=20 ..TextBox2.Text<BR>>> = 'etc.<BR>>> =20 ActiveDocument.Fields.Update<BR>>> End = with<BR>>><BR>>>>=20 guess... Any help is appreciated.. This must have been = done<BR>>>>=20 earlier... ?<BR>>><BR>>><BR>>><BR>>> -- = <BR>>>=20 Salut!<BR>>> _______________________________________<BR>>> = Jean-Guy=20 Marcil - Word MVP<BR>>> </FONT><A=20 href=3D"mailto:jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO"><FONT face=3DArial =
size=3D2>jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO</FONT></A><BR><FONT = face=3DArial=20 size=3D2>>> Word MVP site: </FONT><A = href=3D"http://www.word.mvps.org"><FONT=20 face=3DArial size=3D2>http://www.word.mvps.org</FONT></A><BR><FONT = face=3DArial=20 size=3D2>>> <BR>> <BR>></FONT></BODY></HTML>
------=_NextPart_000_000B_01C6CDBA.551BBC50--
|
|
Marc Jurriens was telling us: Marc Jurriens nous racontait que :
[Quoted Text] > LS, > > Thanks this works now 90%. > > Two puzzling things are still remaining: > > 1) After I have completed the form the fields in the document did not > auto-update, I need to do an update all fields manually.. I added > code to update all fields after the userform gets closed, this > however does not seem to work, the total code now looks like this: > > Private Sub CommandButton1_Click() > Unload UserForm1 > > With Me > ActiveDocument.CustomDocumentProperties("CUSTOMER").Value = > CUSTOMER > ActiveDocument.CustomDocumentProperties("C_SHORT").Value = C_SHORT > ActiveDocument.CustomDocumentProperties("INITIALS").Value = > INITIALS > ActiveDocument.CustomDocumentProperties("OWNER").Value = OWNER > ActiveDocument.CustomDocumentProperties("MANTEL").Value = MANTEL > ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value = > OPENINGHOURS > ActiveDocument.CustomDocumentProperties("DURATION").Value = > DURATION > ActiveDocument.CustomDocumentProperties("VERSION").Value = VERSION > ActiveDocument.CustomDocumentProperties("STATUS").Value = STATUS > ActiveDocument.Fields.Update > End With
I do not see any variable declaration in your code.. So what are CUSTOMER, C_SHORT, INITIALS, etc.? Are we talking about a protected document here?
> End Sub > > Sub UpdateAll() > 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 > > What am I doing wrong ? > > The other thing I notice is that the fields in the userform allways > have the -initial- items in the fields pre-loaded instead of the > latest status of the fields. Anyone any idea how I can fix that ?
Where are those initial items from? Do you mean that we you re-launch the UserForm a second time it contains the default values and not the one that are currently in the document?
To fix that, in the form Initialize event (Double-click on the form itself in the VBE, this will take you to the code pane, then in the dropdown at the top, on the right, select Initialize, you should get a UserForm1_Initialize Sub).
In this Sub, use the reverse of the code I posted before:
With Me .TextBox1.Text = ActiveDocument.CustomDocumentProperties("DocProp_1").Value .TextBox2.Text = ActiveDocument.CustomDocumentProperties("DocProp_2").Value = End with
This will also get executed the first time the userform is used when a new document is created from the template.
So, make sure you have nice default values for each Custom Document Properties you create.
-- Salut! _______________________________________ Jean-Guy Marcil - Word MVP jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO Word MVP site: http://www.word.mvps.org
|
|
"Jean-Guy Marcil" <NoSpam[ at ]LeaveMeAlone> wrote in message news:e$waWmczGHA.5072[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text] > Marc Jurriens was telling us: > Marc Jurriens nous racontait que : > >> LS, >> >> Thanks this works now 90%. >> >> Two puzzling things are still remaining: >> >> 1) After I have completed the form the fields in the document did not >> auto-update, I need to do an update all fields manually.. I added >> code to update all fields after the userform gets closed, this >> however does not seem to work, the total code now looks like this: >> >> Private Sub CommandButton1_Click() >> Unload UserForm1 >> >> With Me >> ActiveDocument.CustomDocumentProperties("CUSTOMER").Value = >> CUSTOMER >> ActiveDocument.CustomDocumentProperties("C_SHORT").Value = C_SHORT >> ActiveDocument.CustomDocumentProperties("INITIALS").Value = >> INITIALS >> ActiveDocument.CustomDocumentProperties("OWNER").Value = OWNER >> ActiveDocument.CustomDocumentProperties("MANTEL").Value = MANTEL >> ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value = >> OPENINGHOURS >> ActiveDocument.CustomDocumentProperties("DURATION").Value = >> DURATION >> ActiveDocument.CustomDocumentProperties("VERSION").Value = VERSION >> ActiveDocument.CustomDocumentProperties("STATUS").Value = STATUS >> ActiveDocument.Fields.Update >> End With > > I do not see any variable declaration in your code.. So what are CUSTOMER, > C_SHORT, INITIALS, etc.? > Are we talking about a protected document here?
These are the names of the Docproperty fields in the document. The document is not protected but that should not matter since I am using fields and not bookmarks..
> >> End Sub >> >> Sub UpdateAll() >> 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 >> >> What am I doing wrong ? >> >> The other thing I notice is that the fields in the userform allways >> have the -initial- items in the fields pre-loaded instead of the >> latest status of the fields. Anyone any idea how I can fix that ? > > Where are those initial items from? > Do you mean that we you re-launch the UserForm a second time it contains > the default values and not the one that are currently in the document? > > To fix that, in the form Initialize event (Double-click on the form itself > in the VBE, this will take you to the code pane, then in the dropdown at > the top, on the right, select Initialize, you should get a > UserForm1_Initialize Sub). > > In this Sub, use the reverse of the code I posted before: > > With Me > .TextBox1.Text = > ActiveDocument.CustomDocumentProperties("DocProp_1").Value > .TextBox2.Text = > ActiveDocument.CustomDocumentProperties("DocProp_2").Value = > End with > > This will also get executed the first time the userform is used when a new > document is created from the template.
I'll try this right away and will let you know !
> > So, make sure you have nice default values for each Custom Document > Properties you create. > > -- > Salut! > _______________________________________ > Jean-Guy Marcil - Word MVP > jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO > Word MVP site: http://www.word.mvps.org >
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0011_01C6D011.BFC814A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hiya !
Preloading the fields works great now ! The system also works great now = when I restart the script a second time.
The one remaining issue is now that -after- I change the fields on the = form I have to manually do an "UPDATE FIELD" to update the fields to the = new values in the document..
As stated I am using document fields (and not bookmarks) to do this = trick.. The CUSTOMER, C_SHORT, etc. are the field names in the document = template I am using.
Do you have a bright idea Jean-Guy ? Maybe the Updateall routine is on = the wrong place in the script ?" I would need it to activate the moment = the userform is closed... I incldue the script code for reference:
Private Sub CommandButton1_Click() Unload UserForm1
With Me ActiveDocument.CustomDocumentProperties("CUSTOMER").Value =3D = CUSTOMER ActiveDocument.CustomDocumentProperties("C_SHORT").Value =3D C_SHORT ActiveDocument.CustomDocumentProperties("INITIALS").Value =3D = INITIALS ActiveDocument.CustomDocumentProperties("OWNER").Value =3D OWNER ActiveDocument.CustomDocumentProperties("MANTEL").Value =3D MANTEL ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value =3D = OPENINGHOURS ActiveDocument.CustomDocumentProperties("DURATION").Value =3D = DURATION ActiveDocument.CustomDocumentProperties("VERSION").Value =3D VERSION ActiveDocument.CustomDocumentProperties("STATUS").Value =3D STATUS ActiveDocument.Fields.Update End With
End Sub
Sub UpdateAll() 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
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
With Me CUSTOMER =3D = ActiveDocument.CustomDocumentProperties("CUSTOMER").Value C_SHORT =3D ActiveDocument.CustomDocumentProperties("C_SHORT").Value INITIALS =3D = ActiveDocument.CustomDocumentProperties("INITIALS").Value OWNER =3D ActiveDocument.CustomDocumentProperties("OWNER").Value MANTEL =3D ActiveDocument.CustomDocumentProperties("MANTEL").Value OPENINGHOURS =3D = ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value DURATION =3D = ActiveDocument.CustomDocumentProperties("DURATION").Value VERSION =3D ActiveDocument.CustomDocumentProperties("VERSION").Value STATUS =3D ActiveDocument.CustomDocumentProperties("STATUS").Value End With
End Sub
------=_NextPart_000_0011_01C6D011.BFC814A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2900.2963" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY> <DIV><FONT face=3DArial size=3D2>Hiya !</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Preloading the fields works great now = ! The=20 system also works great now when I restart the script a second=20 time.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>The one remaining issue is now that = -after- I=20 change the fields on the form I have to manually do an "UPDATE FIELD" to = update=20 the fields to the new values in the document..</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>As stated I am using document fields = (and not=20 bookmarks) to do this trick.. The CUSTOMER, C_SHORT, etc. are the field = names in=20 the document template I am using.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Do you have a bright idea Jean-Guy=20 ? Maybe the Updateall routine is on the wrong place in the = script ?"=20 I would need it to activate the moment the userform is closed... = I incldue=20 the script code for reference:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Private Sub=20 CommandButton1_Click()<BR>Unload UserForm1</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>With = Me<BR> =20 ActiveDocument.CustomDocumentProperties("CUSTOMER").Value =3D=20 CUSTOMER<BR> =20 ActiveDocument.CustomDocumentProperties("C_SHORT").Value =3D=20 C_SHORT<BR> =20 ActiveDocument.CustomDocumentProperties("INITIALS").Value =3D=20 INITIALS<BR> =20 ActiveDocument.CustomDocumentProperties("OWNER").Value =3D=20 OWNER<BR> =20 ActiveDocument.CustomDocumentProperties("MANTEL").Value =3D=20 MANTEL<BR> =20 ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value =3D=20 OPENINGHOURS<BR> =20 ActiveDocument.CustomDocumentProperties("DURATION").Value =3D=20 DURATION<BR> =20 ActiveDocument.CustomDocumentProperties("VERSION").Value =3D=20 VERSION<BR> =20 ActiveDocument.CustomDocumentProperties("STATUS").Value =3D=20 STATUS<BR> ActiveDocument.Fields.Update<BR>End=20 With</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>End Sub</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Sub UpdateAll()<BR>Dim = oStory As=20 Range<BR>Dim oField As Field<BR> For Each oStory In=20 ActiveDocument.StoryRanges<BR> For Each oField In=20 oStory.Fields<BR> =20 oField.Update<BR> Next oField<BR> Next = oStory<BR>End=20 Sub</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Private Sub=20 UserForm_Click()</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>End Sub</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Private Sub=20 UserForm_Initialize()</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>With = Me<BR> =20 CUSTOMER =3D=20 ActiveDocument.CustomDocumentProperties("CUSTOMER").Value<BR> = =20 C_SHORT =3D=20 ActiveDocument.CustomDocumentProperties("C_SHORT").Value<BR> &= nbsp;=20 INITIALS =3D=20 ActiveDocument.CustomDocumentProperties("INITIALS").Value<BR> = =20 OWNER =3D=20 ActiveDocument.CustomDocumentProperties("OWNER").Value<BR> &nb= sp;=20 MANTEL =3D=20 ActiveDocument.CustomDocumentProperties("MANTEL").Value<BR> &n= bsp;=20 OPENINGHOURS =3D=20 ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value<BR> &n= bsp; =20 DURATION =3D=20 ActiveDocument.CustomDocumentProperties("DURATION").Value<BR> = =20 VERSION =3D=20 ActiveDocument.CustomDocumentProperties("VERSION").Value<BR> &= nbsp;=20 STATUS =3D = ActiveDocument.CustomDocumentProperties("STATUS").Value<BR>End=20 With</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><BR><FONT face=3DArial color=3D#0000ff size=3D1>End = Sub</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_0011_01C6D011.BFC814A0--
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_000B_01C6D020.6D4558F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Guys,
Played along with it a bit more and it works now. To make everything = complete I include the code herein:
Private Sub CommandButton1_Click() Unload UserForm1
With Me ActiveDocument.CustomDocumentProperties("CUSTOMER").Value =3D = CUSTOMER ActiveDocument.CustomDocumentProperties("C_SHORT").Value =3D C_SHORT ActiveDocument.CustomDocumentProperties("INITIALS").Value =3D = INITIALS ActiveDocument.CustomDocumentProperties("OWNER").Value =3D OWNER ActiveDocument.CustomDocumentProperties("MANTEL").Value =3D MANTEL ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value =3D = OPENINGHOURS ActiveDocument.CustomDocumentProperties("DURATION").Value =3D = DURATION ActiveDocument.CustomDocumentProperties("VERSION").Value =3D VERSION ActiveDocument.CustomDocumentProperties("STATUS").Value =3D STATUS ActiveDocument.Fields.Update End With
End Sub
Private Sub UserForm_Initialize()
With Me CUSTOMER =3D = ActiveDocument.CustomDocumentProperties("CUSTOMER").Value C_SHORT =3D ActiveDocument.CustomDocumentProperties("C_SHORT").Value INITIALS =3D = ActiveDocument.CustomDocumentProperties("INITIALS").Value OWNER =3D ActiveDocument.CustomDocumentProperties("OWNER").Value MANTEL =3D ActiveDocument.CustomDocumentProperties("MANTEL").Value OPENINGHOURS =3D = ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value DURATION =3D = ActiveDocument.CustomDocumentProperties("DURATION").Value VERSION =3D ActiveDocument.CustomDocumentProperties("VERSION").Value STATUS =3D ActiveDocument.CustomDocumentProperties("STATUS").Value End With
End Sub
Private Sub UserForm_Terminate()
ActiveDocument.CustomDocumentProperties("CUSTOMER").Value =3D CUSTOMER ActiveDocument.CustomDocumentProperties("C_SHORT").Value =3D C_SHORT ActiveDocument.CustomDocumentProperties("INITIALS").Value =3D INITIALS ActiveDocument.CustomDocumentProperties("OWNER").Value =3D OWNER ActiveDocument.CustomDocumentProperties("MANTEL").Value =3D MANTEL ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value =3D = OPENINGHOURS ActiveDocument.CustomDocumentProperties("DURATION").Value =3D DURATION ActiveDocument.CustomDocumentProperties("VERSION").Value =3D VERSION ActiveDocument.CustomDocumentProperties("STATUS").Value =3D STATUS ActiveDocument.Fields.Update
Dim pRange As Word.Range Dim iLink As Long iLink =3D ActiveDocument.Sections(1).Headers(1).Range.StoryType For Each pRange In ActiveDocument.StoryRanges Do pRange.Fields.Update Set pRange =3D pRange.NextStoryRange Loop Until pRange Is Nothing Next
With ActiveDocument .SaveAs "SA -" & .CustomDocumentProperties("C_SHORT").Value & " - " = & .CustomDocumentProperties("VERSION").Value & ".doc" End With
End Sub
Thanks all for the help ! Now on to my next issue, see seperate post ;-)
"Marc Jurriens" <helmonder[ at ]hotmail.com> wrote in message = news:%23Qae$DA0GHA.1040[ at ]TK2MSFTNGP06.phx.gbl... Hiya !
Preloading the fields works great now ! The system also works great = now when I restart the script a second time.
The one remaining issue is now that -after- I change the fields on the = form I have to manually do an "UPDATE FIELD" to update the fields to the = new values in the document..
As stated I am using document fields (and not bookmarks) to do this = trick.. The CUSTOMER, C_SHORT, etc. are the field names in the document = template I am using.
Do you have a bright idea Jean-Guy ? Maybe the Updateall routine is = on the wrong place in the script ?" I would need it to activate the = moment the userform is closed... I incldue the script code for = reference:
Private Sub CommandButton1_Click() Unload UserForm1
With Me ActiveDocument.CustomDocumentProperties("CUSTOMER").Value =3D = CUSTOMER ActiveDocument.CustomDocumentProperties("C_SHORT").Value =3D = C_SHORT ActiveDocument.CustomDocumentProperties("INITIALS").Value =3D = INITIALS ActiveDocument.CustomDocumentProperties("OWNER").Value =3D OWNER ActiveDocument.CustomDocumentProperties("MANTEL").Value =3D MANTEL ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value =3D = OPENINGHOURS ActiveDocument.CustomDocumentProperties("DURATION").Value =3D = DURATION ActiveDocument.CustomDocumentProperties("VERSION").Value =3D = VERSION ActiveDocument.CustomDocumentProperties("STATUS").Value =3D STATUS ActiveDocument.Fields.Update End With
End Sub
Sub UpdateAll() 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
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
With Me CUSTOMER =3D = ActiveDocument.CustomDocumentProperties("CUSTOMER").Value C_SHORT =3D = ActiveDocument.CustomDocumentProperties("C_SHORT").Value INITIALS =3D = ActiveDocument.CustomDocumentProperties("INITIALS").Value OWNER =3D ActiveDocument.CustomDocumentProperties("OWNER").Value MANTEL =3D ActiveDocument.CustomDocumentProperties("MANTEL").Value OPENINGHOURS =3D = ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value DURATION =3D = ActiveDocument.CustomDocumentProperties("DURATION").Value VERSION =3D = ActiveDocument.CustomDocumentProperties("VERSION").Value STATUS =3D ActiveDocument.CustomDocumentProperties("STATUS").Value End With
End Sub
------=_NextPart_000_000B_01C6D020.6D4558F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2900.2963" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Guys,</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Played along with it a bit more and it = works now.=20 To make everything complete I include the code herein:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Private Sub=20 CommandButton1_Click()<BR>Unload UserForm1</FONT></DIV> <DIV><FONT color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>With = Me<BR> =20 ActiveDocument.CustomDocumentProperties("CUSTOMER").Value =3D=20 CUSTOMER<BR> =20 ActiveDocument.CustomDocumentProperties("C_SHORT").Value =3D=20 C_SHORT<BR> =20 ActiveDocument.CustomDocumentProperties("INITIALS").Value =3D=20 INITIALS<BR> =20 ActiveDocument.CustomDocumentProperties("OWNER").Value =3D=20 OWNER<BR> =20 ActiveDocument.CustomDocumentProperties("MANTEL").Value =3D=20 MANTEL<BR> =20 ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value =3D=20 OPENINGHOURS<BR> =20 ActiveDocument.CustomDocumentProperties("DURATION").Value =3D=20 DURATION<BR> =20 ActiveDocument.CustomDocumentProperties("VERSION").Value =3D=20 VERSION<BR> =20 ActiveDocument.CustomDocumentProperties("STATUS").Value =3D=20 STATUS<BR> ActiveDocument.Fields.Update<BR>End=20 With</FONT></DIV> <DIV><FONT color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>End Sub</FONT></DIV> <DIV><FONT color=3D#0000ff size=3D1></FONT> </DIV><FONT = face=3DArial size=3D2> <DIV><BR><FONT color=3D#0000ff size=3D1>Private Sub=20 UserForm_Initialize()</FONT></DIV> <DIV><FONT color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT color=3D#0000ff size=3D1>With Me<BR> = CUSTOMER =3D=20 ActiveDocument.CustomDocumentProperties("CUSTOMER").Value<BR> = =20 C_SHORT =3D=20 ActiveDocument.CustomDocumentProperties("C_SHORT").Value<BR> &= nbsp;=20 INITIALS =3D=20 ActiveDocument.CustomDocumentProperties("INITIALS").Value<BR> = =20 OWNER =3D=20 ActiveDocument.CustomDocumentProperties("OWNER").Value<BR> &nb= sp;=20 MANTEL =3D=20 ActiveDocument.CustomDocumentProperties("MANTEL").Value<BR> &n= bsp;=20 OPENINGHOURS =3D=20 ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value<BR> &n= bsp; =20 DURATION =3D=20 ActiveDocument.CustomDocumentProperties("DURATION").Value<BR> = =20 VERSION =3D=20 ActiveDocument.CustomDocumentProperties("VERSION").Value<BR> &= nbsp;=20 STATUS =3D = ActiveDocument.CustomDocumentProperties("STATUS").Value<BR>End=20 With</FONT></DIV> <DIV><FONT color=3D#0000ff size=3D1></FONT> </DIV> <DIV><BR><FONT color=3D#0000ff size=3D1>End Sub</FONT></DIV> <DIV><FONT color=3D#0000ff size=3D1></FONT> </DIV> <DIV><BR><FONT color=3D#0000ff size=3D1>Private Sub=20 UserForm_Terminate()</FONT></DIV> <DIV><FONT color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT color=3D#0000ff=20 size=3D1>ActiveDocument.CustomDocumentProperties("CUSTOMER").Value =3D=20 CUSTOMER<BR>ActiveDocument.CustomDocumentProperties("C_SHORT").Value =3D =
C_SHORT<BR>ActiveDocument.CustomDocumentProperties("INITIALS").Value =3D =
INITIALS<BR>ActiveDocument.CustomDocumentProperties("OWNER").Value =3D=20 OWNER<BR>ActiveDocument.CustomDocumentProperties("MANTEL").Value =3D=20 MANTEL<BR>ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value = =3D=20 OPENINGHOURS<BR>ActiveDocument.CustomDocumentProperties("DURATION").Value= =3D=20 DURATION<BR>ActiveDocument.CustomDocumentProperties("VERSION").Value =3D =
VERSION<BR>ActiveDocument.CustomDocumentProperties("STATUS").Value =3D=20 STATUS<BR>ActiveDocument.Fields.Update</FONT></DIV> <DIV><FONT color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT color=3D#0000ff size=3D1>Dim pRange As Word.Range<BR>Dim = iLink As=20 Long<BR>iLink =3D = ActiveDocument.Sections(1).Headers(1).Range.StoryType<BR>For=20 Each pRange In ActiveDocument.StoryRanges<BR> =20 Do<BR> =20 pRange.Fields.Update<BR> Set = pRange =3D=20 pRange.NextStoryRange<BR> Loop Until pRange Is=20 Nothing<BR>Next</FONT></DIV> <DIV><FONT color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT color=3D#0000ff size=3D1>With = ActiveDocument<BR> =20 ..SaveAs "SA -" & .CustomDocumentProperties("C_SHORT").Value & " = - "=20 & .CustomDocumentProperties("VERSION").Value & ".doc"<BR>End=20 With</FONT></DIV> <DIV><FONT color=3D#0000ff size=3D1></FONT> </DIV> <DIV><BR><FONT color=3D#0000ff size=3D1>End Sub</FONT><BR></DIV> <DIV> </DIV> <DIV>Thanks all for the help ! Now on to my next issue, see seperate = post=20 ;-)</DIV> <DIV> </DIV></FONT> <BLOCKQUOTE dir=3Dltr=20 style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; = BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV>"Marc Jurriens" <<A=20 href=3D"mailto:helmonder[ at ]hotmail.com">helmonder[ at ]hotmail.com</A>> = wrote in=20 message <A=20 = href=3D"news:%23Qae$DA0GHA.1040[ at ]TK2MSFTNGP06.phx.gbl">news:%23Qae$DA0GHA.= 1040[ at ]TK2MSFTNGP06.phx.gbl</A>...</DIV> <DIV><FONT face=3DArial size=3D2>Hiya !</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Preloading the fields works great now = ! The=20 system also works great now when I restart the script a second=20 time.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>The one remaining issue is now that = -after- I=20 change the fields on the form I have to manually do an "UPDATE FIELD" = to=20 update the fields to the new values in the document..</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>As stated I am using document fields = (and not=20 bookmarks) to do this trick.. The CUSTOMER, C_SHORT, etc. are the = field names=20 in the document template I am using.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Do you have a bright idea Jean-Guy=20 ? Maybe the Updateall routine is on the wrong place in the = script=20 ?" I would need it to activate the moment the userform is closed...=20 I incldue the script code for reference:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Private Sub=20 CommandButton1_Click()<BR>Unload UserForm1</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>With = Me<BR> =20 ActiveDocument.CustomDocumentProperties("CUSTOMER").Value =3D=20 CUSTOMER<BR> =20 ActiveDocument.CustomDocumentProperties("C_SHORT").Value =3D=20 C_SHORT<BR> =20 ActiveDocument.CustomDocumentProperties("INITIALS").Value =3D=20 INITIALS<BR> =20 ActiveDocument.CustomDocumentProperties("OWNER").Value =3D=20 OWNER<BR> =20 ActiveDocument.CustomDocumentProperties("MANTEL").Value =3D=20 MANTEL<BR> =20 ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value =3D=20 OPENINGHOURS<BR> =20 ActiveDocument.CustomDocumentProperties("DURATION").Value =3D=20 DURATION<BR> =20 ActiveDocument.CustomDocumentProperties("VERSION").Value =3D=20 VERSION<BR> =20 ActiveDocument.CustomDocumentProperties("STATUS").Value =3D=20 STATUS<BR> ActiveDocument.Fields.Update<BR>End=20 With</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>End Sub</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Sub = UpdateAll()<BR>Dim oStory As=20 Range<BR>Dim oField As Field<BR> For Each oStory In=20 ActiveDocument.StoryRanges<BR> For Each oField In=20 oStory.Fields<BR> =20 oField.Update<BR> Next oField<BR> Next = oStory<BR>End=20 Sub</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Private Sub=20 UserForm_Click()</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>End Sub</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>Private Sub=20 UserForm_Initialize()</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1>With = Me<BR> =20 CUSTOMER =3D=20 = ActiveDocument.CustomDocumentProperties("CUSTOMER").Value<BR> = =20 C_SHORT =3D=20 = ActiveDocument.CustomDocumentProperties("C_SHORT").Value<BR> &= nbsp;=20 INITIALS =3D=20 = ActiveDocument.CustomDocumentProperties("INITIALS").Value<BR> = =20 OWNER =3D=20 = ActiveDocument.CustomDocumentProperties("OWNER").Value<BR> &nb= sp;=20 MANTEL =3D=20 = ActiveDocument.CustomDocumentProperties("MANTEL").Value<BR> &n= bsp;=20 OPENINGHOURS =3D=20 = ActiveDocument.CustomDocumentProperties("OPENINGHOURS").Value<BR> &n= bsp; =20 DURATION =3D=20 = ActiveDocument.CustomDocumentProperties("DURATION").Value<BR> = =20 VERSION =3D=20 = ActiveDocument.CustomDocumentProperties("VERSION").Value<BR> &= nbsp;=20 STATUS =3D = ActiveDocument.CustomDocumentProperties("STATUS").Value<BR>End=20 With</FONT></DIV> <DIV><FONT face=3DArial color=3D#0000ff size=3D1></FONT> </DIV> <DIV><BR><FONT face=3DArial color=3D#0000ff size=3D1>End = Sub</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial = size=3D2></FONT> </DIV></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_000B_01C6D020.6D4558F0--
|
|
|