Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    How to switch (toggle) pictures in a Header (Office XP Word 2000)

    Hi,

    I have earlier got very good help from Hans with the following procedure. It makes logos (picture) in a Header visible and not visible.
    It was a great success and now I'm asking:

    Is there a way I can switch between two or more logos and also keep the possibility to switch them off?



    Sub ToggleLogosOnOffNo()
    Dim cmdToggleLogosText As String
    Dim sec As Section
    Dim hdr As HeaderFooter
    Dim fld As Field
    Dim rng As Range
    Dim i As Long

    For Each sec In ActiveDocument.Sections
    For Each hdr In sec.Headers
    Set rng = hdr.Range

    For i = 1 To rng.ShapeRange.Count
    With rng.ShapeRange(i)
    .Visible = Not .Visible
    End With
    Next i

    Next hdr
    Next sec
    If cmdToggleLogosOnOff.Caption = "Hide Logos" Then
    cmdToggleLogosOnOff.Caption = "Show Logos"
    ActiveDocument.CustomDocumentProperties("LOGOSVISI BLE") = False
    Else
    cmdToggleLogosOnOff.Caption = "Hide Logos"
    ActiveDocument.CustomDocumentProperties("LOGOSVISI BLE") = True
    End If

    Set fld = Nothing
    Set rng = Nothing
    Set hdr = Nothing
    Set sec = Nothing
    cmdOK_Click
    End Sub

    If this is possible I may only need one template and be able to choose between black and colored logos.

    Thanks a lot if anyone could give me a solution or some help!!!

    bjorn

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to switch (toggle) pictures in a Header (Office XP Word 2000)

    Making *all* pictures invisible is simple:

    For i = 1 To rng.ShapeRange.Count
    With rng.ShapeRange(i)
    .Visible = False
    End With
    Next i

    but if you want to be able to choose between pictures, you must have some way to distinguish between them. One way to do this is through their Name property (floating pictures have a name, inline pictures don't.) On my system, they are named Picture 1, Picture 2, etc. by default, but you can rename them with instructions like these:

    ActiveDocument.Sections(1).Headers(wdHeaderFooterP rimary).Shapes(1).Name = "Bjorn"

    By applying a systematic naming scheme you'll be able to identify the pictures. For example, use a prefix or postfix to indicate the group to which the pictures belong.

    Note: your documents may become very big when you store large numbers of pictures, only a few of which are displayed at a time. An alternative might be to store the pictures in the template as AutoText entries, and each time you want to show a different set of pictures, delete the existing ones, and insert the appropriate AutoText entries in the appropriate places. This might be more work, though.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: How to switch (toggle) pictures in a Header (Office XP Word 2000)

    Thanks Hans!

    I will look into these possibilities and have it a try. In my case it should be changing between two logos (colored and black) and one choice of no logo. The logos are gif files and should not contribute too much to the file size (?).

    Anyway, thanks again Hans. Its about 16:30 here now and a trip home will be good for the spirit.

    Thanks!


    Bjorn

  4. #4
    New Lounger
    Join Date
    Nov 2003
    Location
    Sofia
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to switch (toggle) pictures in a Header (Office XP Word 2000)

    You can make your document a mail merge document and put your pictures in mail merge fields.


    Another option is to use an IF field:

    1. Create a custom document property, e.g. "DocVersion".

    2. Use an ASK field to enter a value in that property. You will be prompted for the document version whenever the field is updated.

    {ASK DocVersion "BW or Color" DocVersion *MERGEFORMAT}

    3. Create an IF field in the place where the logo should be inserted. The IF filed checks the content of the DocVersion property; if DocVersion matches certain value, the IF field should insert Picture1, else Picture 2. You can easily do this from the Mail Merge toolbar.

    {IF DocVersion "BW" "BW pic here" "Color pic here" * MERGEFORMAT}

  5. #5
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: How to switch (toggle) pictures in a Header (Office XP Word 2000)

    Thanks

    I will look into this as well. Though since i have only two logos inserted in the document Header the size will not be great.

    But thanks, I then will look into this when it comes some spare time.

    Bjorn

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to switch (toggle) pictures in a Header (O

    Hi petkom:
    I'm a little confused by the first step of your solution. I can't update a DocProperty using an ASK field. On the other hand, if I create a bookmark by the name of DocVersion or use the ASK field to create the bookmark, then the IF field

    {IF DocVersion <font color=red>=</font color=red> "BW" "BW pic here" "Color pic here" * MERGEFORMAT}

    will choose the BW or color picture. Note that I had to also insert an = sign. So far as I know, the IF field will check the bookmark, not the DocProperty. However,

    {IF {DocProperty DocVersion} = BW "BW pic here" "Color pic here" * MERGEFORMAT}
    will check the value of the custom DocVersion property. Still, I don't know how you can change that with an ASK field.

  7. #7
    New Lounger
    Join Date
    Nov 2003
    Location
    Sofia
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to switch (toggle) pictures in a Header (Office XP Word 2000)

    Hi, Phil.

    Yes, you're right. The ASK field stores the content in a bookmark, not in a Doc Property field. So forget about creating a custom field

Posting Permissions

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