Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Houston, Texas, USA
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Copy Styles macro - global.dot (XP)

    I am trying to record a macro in our firm's global.dot which would copy the firm standard paragraph styles from blank.dot to a document which has been created using another outside template. While in global.dot, I am unable to get to Attach in Templates and AddIns as it is grayed out.

    Can someone help with code which do the following:

    1. Open Templates and Addins
    2. Choose Attach and open our blank.dot file
    3. Select "Automatically Update Document Styles".
    4. Click OK, then return to Templates and Addins
    5. Deselect "Automatically Update Document Styles".

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

    Re: Copy Styles macro - global.dot (XP)

    This should do it (not all steps in the "manual" procedure are necessary in the macro)

    With ActiveDocument
    .AttachedTemplate = "serversharefoldersGlobal.dot"
    .UpdateStyles
    End With

    This leaves Global.dot as the attached template.

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    Houston, Texas, USA
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy Styles macro - global.dot (XP)

    Thanks again, Hans

    I am going to dust off my VBA manual this weekend :-)

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

    Re: Copy Styles macro - global.dot (XP)

    Hi Hans:
    I tried to use the code by creating the following procedure, but it didn't work. I got an error saying " Run time error 5947. Couldn't change document template". Do you know why?<pre>Sub ChangeAttachedTemplate()
    With ActiveDocument
    .AttachedTemplate = "C:WINDOWSApplication Data _
    MicrosoftTemplatesLettersLetter.dot"
    .UpdateStyles
    End With
    End Sub</pre>

    Thanks,

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Brussels, Brussel, Belgium
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy Styles macro - global.dot (XP)

    hi Phil,

    i am puzzled. the code you provide should generate a compile error (syntax error), because the line-continuation character is used to split up a string, which is not allowed.
    to split up a string over multiple lines, you need to open and close each string on every line of code and concatenate using the ampersand operator :

    .attachedtemplate="C:WINDOWSApplication Data " & _
    "MicrosoftTemplatesLettersLetter.dot"

  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: Copy Styles macro - global.dot (XP)

    Hi Pieter:
    Thanks. I'm sorry. I used the line continuation character just in the post because it was too long. In the actual procedure, I have it on one line. I still get an error message though.

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

    Re: Copy Styles macro - global.dot (XP)

    Strange. If the path is correct, it should run, I think. It does for me if I substitute the path and file name of a template on my system. Although that's Word 2002, I am almost sure I did things like that in Word 97 too, and I can hardly believe that Word 2000 would be different.

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

    Re: Copy Styles macro - global.dot (XP)

    I'll try again, using the winword.exe /a switch. Maybe there's a conflict with another macro or add-in. I guess I could always follow the steps in <post#=197827>post 197827</post#>. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  9. #9
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Copy Styles macro - global.dot (XP)

    Phil

    My guess is that you are trying to attach the template to a TEMPLATE. You can't do that. Make sure you are working in a document and try the code again.

    I am assuming you added the space underscore for display here and that is not part of your code
    Andrew Lockton, Chrysalis Design, Melbourne Australia

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

    Re: Copy Styles macro - global.dot (XP)

    Hi Everyone:
    I got it to work. I hadn't realized that the code must be in the attached template. <img src=/S/doh.gif border=0 alt=doh width=15 height=15> I created a document & put the code in the document, rather than in normal or another global template. <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30> When I put the code in either normal or another global template, it worked fine. Thanks for all the responses.

Posting Permissions

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