Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jul 2003
    Location
    Burnaby, Br. Columbia, Canada
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving defaults to Normal.dot (VBA Word 2003)

    Hi, I am doing something I thought would be quite simple, but it isn't working. Basically, I am trying to set the default of the left and right margins in the Normal template through VBA. From what I understand it should be the following code...

    With ActiveDocument.PageSetup
    .LeftMargin = InchesToPoints(1)
    .RightMargin = InchesToPoints(1)
    .SetAsTemplateDefault
    End With

    While this code does change the margins for the active document, it does not set them in Normal.dot, so any new documents are still using the old margin settings. It doesn't generate any errors, it simply doesn't do it.

    I tried saving the active document after running the code, because I know that seems to be the trick when trying to save styles to the attached template, but that didn't change anything. Any ideas would be appreciated!

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving defaults to Normal.dot (VBA Word 2003)

    DEfaults for a New document are whatever is used by the actual document in Normal.dot.

    Your choices are to OPen Normal.dot directly and save the critter any way you wish, or, create AutoNew macros that apply appropriate settings.
    I prefer doing the latter.

  3. #3
    Lounger
    Join Date
    Jul 2003
    Location
    Burnaby, Br. Columbia, Canada
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving defaults to Normal.dot (VBA Word 2003)

    Thanks Howard. I understand that standard new documents are based on Normal.dot. I would rather not have to open the user's Normal.dot to do this, especially when the code I am trying to use is 'supposed to', according to VBA Help, save the settings to the attached template, basically doing the equivalent of clicking the Default button in a dialog box like File, Page Setup.

    I don't think AutoNew macros are going to work for what we are trying to achieve, which is basically that the user can click a button on their toolbar (so it is self-invoked) which will in turn set a number of our corporate 'standard' defaults in their Normal.dot for them. We want them to be able to do this if they choose (hence they run it from a button), and we are coding it so that they don't have to 'know' the standards and do them one at a time on their own. We are setting the language, margins, font, and copying in our standard styles. The language setting works fine, and copying the standard styles to Normal.dot works fine. But the .SetAsTemplateDefault for the l/r margins is not working.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving defaults to Normal.dot (VBA Word 2003)

    Have the toolbar buton use the same code.that would be in AutoNew.

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Saving defaults to Normal.dot (VBA Word 2003)

    You could force the changes by using the following SendKeys routine after your code

    SendKeys "%DY"
    Dialogs(wdDialogFilePageSetup).Show

    This works for me (using Word XP), though it does flash the Page Setup dialog on screen.

  6. #6
    Lounger
    Join Date
    Jul 2003
    Location
    Burnaby, Br. Columbia, Canada
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving defaults to Normal.dot (VBA Word 2003)

    Thanks all for your input. In the end I decided to use the following code (provided by Helmut on another forum):

    Dim oDot As Document
    Set oDot = Documents.Open(strUserTemplateDir & Application.PathSeparator & pcNormal, Visible:=False)
    With oDot
    .PageSetup.LeftMargin = InchesToPoints(1)
    .PageSetup.RightMargin = InchesToPoints(1)
    .Styles(wdStyleNormal).Font.Name = "Times New Roman"
    .Styles(wdStyleNormal).Font.Size = 12
    .Save
    .Close
    End With

    Ultimately I wanted to modify the user's Normal.dot to set their defaults, when they invoke it (i.e., click a button). I originally wanted to do it using the equivalent of the 'Default' button in Page Setup, Font and Language dialog boxes, mainly so that I wouldn't have to open the Normal.dot, because I didn't want the user to see the Normal.dot opened and closed. Helmut's code provided the perfect solution, which opens the Normal.dot to edit it, and doesn't make it visible to the user. Not surprising that the original code I was trying to use, which was from the Word VBA Help, didn't do what it was supposed to!

Posting Permissions

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