Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word 2010 change DefaultFilePath(wdStartupPath /wdUserTemplatesPath)

    Hallo,
    i have a problem to change DefaultFilePath(wdStartupPath) and DefaultFilePath(wdUserTemplatesPath)

    My vbs script:
    On Error Resume Next
    Set objWord = CreateObject("Word.Application")
    objWord.Options.DefaultFilePath(wdStartupPath) = "C:\"
    objWord.Options.DefaultFilePath(wdUserTemplatesPat h) = "D:\Templates"
    objWord.Quit

    After that the vbs script set my DefaultFilePath(wdStartupPath) every time to D:\Templates and the UserTemplatesPath will not be changed.

    Can you help me :-(?

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,515
    Thanks
    3
    Thanked 143 Times in 136 Posts
    I believe you need to change the word constants to their integer values if this is running from a vbs script.
    Code:
    On Error Resume Next
    Set objWord = CreateObject("Word.Application")
    objWord.Options.DefaultFilePath(8) = "C:\"
    objWord.Options.DefaultFilePath(2) = "D:\Templates"
    objWord.Quit
    FWIW, on a machine where I know the version of Word being used, I write directly to the registry
    Code:
    Dim SysVarReg, sValue
    sValue = "D:\Work\Templates"	
    Set SysVarReg = WScript.CreateObject("WScript.Shell")
    SysVarReg.RegWrite "HKCU\Software\Microsoft\Office\14.0\Common\General\UserTemplates", sValue
    
    sValue = "D:\Work\Templates\Startup"		
    SysVarReg.RegWrite "HKCU\Software\Microsoft\Office\14.0\Common\General\Startup", sValue
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    New Lounger
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Great :-)
    thank you very much for your help...
    It works great...

    YEAHHHHHHHH

  4. #4
    New Lounger
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dear Andrew,
    i have an additional question...
    I want to change standard font (Calibri 11), i want Arial 11 when i start Word 2010.
    The Normal.dotm is in this folder: Y:\Office\Vorlagen\Normal.dotm

    I tried the following code, but nothing changed:

    Set objWord = CreateObject("Word.Application")
    Set WshShell = CreateObject("WScript.Shell")
    Set WshSysEnv = WshShell.Environment("PROCESS")

    objWord.Options.DefaultFilePath(0) = "G:\"
    objWord.Options.DefaultFilePath(2) = "Y:\Office\Vorlagen"

    objWord.Visible = False
    Set objDoc = objWord.Documents.Open(WshSysEnv("APPDATA") + "Y:\Office\Vorlagen\Normal.dotm", False)
    Set objSelection = objWord.Selection

    objSelection.Font.Name = "Arial"
    objSelection.Font.Size = "11"

    objWord.Quit

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,515
    Thanks
    3
    Thanked 143 Times in 136 Posts
    Changing the selection in Normal is not going to work since that is a local change which only affects the insertion point and is not changing the underlying styles. To change the 'default' fonts in the Normal template for Word 2010 you should be looking to change the Normal style and/or the theme fonts. Something like the following should work if Word is not already open.

    Code:
    Set objWord = CreateObject("Word.Application")
    'Set objDoc = objWord.Documents.Open("Y:\Office\Vorlagen\Normal.dotm", False)
    With objDoc.Styles("Normal").Font
      .Name = "Arial"
      .Size = 11
    End With
    objWord.Quit
    If you find this is not working then it may be because Word is already open and therefore you don't have exclusive access to the template. Usually we use more complicated code to first check if Word is already open (using GetObject) before creating the object.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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