Results 1 to 5 of 5
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    can i do this with fieldcodes (Word 2002 XP SR3)

    I would like to insert a fieldcode into documents

    The fieldcode calls and displays an address.

    The address is set in the fieldcode as "MEL"

    { PRINT p page (MEL_LTR_PS) 0 GetOvr" * MERGEFORMAT}

    The address will change depending on which office the user is in physically located.

    Therefore the address is to change to either:
    BRI
    GOL
    MEL
    PER
    SYD


    My question is in a fieldcode how can i updated and change the "address"?

    I have been experimenting with the fieldcodes using "Set State" but I still need a trigger, to determine and change to the relevant state. (see below pic)

    I have an .ini file that stores the address. I have code that obtains the address in the ini file, but i dont know how to do it using a fieldcode.


    any ideas?

    thank you

    diana
    Attached Images Attached Images

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: can i do this with fieldcodes (Word 2002 XP SR3)

    Hi Diana,

    For the print field, you could use field coding like:
    {PRINT p page "({IF{State}= 1 BRI {IF{State}= 2 GOL {IF{State}= 3 MEL {IF{State}= 4 PER {IF{State}= 5 SYD {IF{State}= 6 AAA {IF{State}= 7 BBB {IF{State}= 8 CCC}}}}}}}}__LTR_PS) 0 GetOvr" }

    That's easy.

    As for getting the State, I'd suggest modifying the document templates for each location to include the city name in the document properties (see File|Properties) under, say, the 'Company' field as the last string in that field. Then you could test that field directly, as in:
    {PRINT p page "({IF{DOCPROPERTY "Company"}= "*Brisbane" BRI {IF{DOCPROPERTY "Company"}= "*Gold Coast" GOL {IF{DOCPROPERTY "Company"}= "*Melbourne" MEL}}}__LTR_PS) 0 GetOvr" }
    and so on.

    In Word, you can nest up to 20 IF fields. An alternative way to do the same thing without nesting would be:
    {PRINT p page "({IF{DOCPROPERTY "Company"}= "*Brisbane" BRI}{IF{DOCPROPERTY "Company"}= "*Gold Coast" GOL}{IF{DOCPROPERTY "Company"}= "*Melbourne" MEL}__LTR_PS) 0 GetOvr" }
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: can i do this with fieldcodes (Word 2002 XP SR3)

    Thank you Macropod

    The template is a national template, thats used in each state. For ease of maintenance we dont have state based templates.

    Is there another way to obtain the current state?

    I was playing around with FormFields. The field can be set to run a macro on entry, or exit of the formfield. I have code that obtains the current state from the ini file.

    However I still need a trigger point for the formfield. On a print command do you think I could capture & set the formfield?

    And with setting the standard "IF" I'll need a trigger point to set the state. I dont want manual input from the user

    thank you

    diana
    Attached Images Attached Images

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: can i do this with fieldcodes (Word 2002 XP SR3)

    Hi Diana,

    An 'on exit' macro attached to any suitable formfield, or even multiple formfields, could be set to read the ini file, for which you say you have the code, and put its value into a bookmarked location within the PRINT field. The code to do update the bookmark in the PRINT field might look like:<pre>Sub UpdatePrnFld(StateID as string)
    If Documents.Count > 0 then
    If ActiveDocument.Bookmarks.Exists("PrnBkMrk") Then
    Set BmkRng = ActiveDocument.Bookmarks("PrnBkMrk").Range
    BmkRng.Text = StateID
    ActiveDocument.Bookmarks.Add "PrnBkMrk", BmkRng
    End if
    End if
    Set BmkRng = Nothing
    End sub</pre>

    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: can i do this with fieldcodes (Word 2002 XP SR3)

    Thank you Macropod

    I was wanting to add the form field in the header, but Word wont allow you to add form fields in the header. On pasting a form field in the header Word displays the message "You cannot paste form fields into comments, headers...."

    If I want to insert the field into a header should I then use a "normal" field? if using a normal fieldcode how would I call the code?

    If I use a "macrobutton" fieldcode, interaction is required by a use to double clickt to kick off the macro

    diana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •