Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Save a document using staff number (Word 2000)

    Hi there
    I would like a user to save a template to his personal folders (designated by his employee number eg p999999) by means of a macro. The path will be something like Cocuments and Settings[his employee number folder]Applicatin DataMicrosoftTemplates.
    Could a request box ask the user for his employee number and then this information used in the path?
    Regards

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

    Re: Save a document using staff number (Word 2000)

    You don't need to ask the user.
    <code>Options.DefaultFilePath(wdUserTemplatesPath) </code> will return the user templates folder.

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save a document using staff number (Word 2000)

    Hans, may ignorance is showing!
    I run the code as follows: ActiveDocument.SaveAs FileName:=Options.DefaultFilePath(wdUserTemplatesP ath)
    and the Test.dot document is saved one level above the Templates folder i.e below Microsoft with a file name of Templates.dot.
    I actually want to retain the original template name "FSMaster.dot" and save it inside the Templates folder so that the user can access it from the File > New option.
    Any other way?
    Regards

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

    Re: Save a document using staff number (Word 2000)

    You are saving the document with the name of a folder, and you don't specify the file name or the file type. Try this:

    ActiveDocument.SaveAs FileName:=Options.DefaultFilePath(wdUserTemplatesP ath) & "FSMaster.dot", FileFormat:=wdFormatTemplate

  5. #5
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save a document using staff number (Word 2000)

    Yes, yes, yes. I am forever grateful.
    Regards

  6. #6
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save a document using staff number (Word 2000)

    Hans
    Could you assist further.
    How would I change this code to save the template to the users Word STARTUP folder so that the macros are available any time? Like a global template.
    At the moment when I run the code on another machine the template is saved to the correct folder for the user but the toolbar attached to the template disappears. It is not listed under any of the toolbars. The toolbar is what activates the macros - without it the document is useless!
    Regards

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save a document using staff number (Word 2000)

    >How would I change this code to save the template to the users Word STARTUP folde

    This may be overkill, but here's my code for obtaining the Startup Folder for a template-instalaltion package.

    <pre>Public Function strGetStartUpFolder() As String
    ' Obtain the existing STARTUP Folder path.
    ' If it does not exist, suggest a path to the user
    Dim strResult As String
    strResult = Application.StartupPath
    If strResult = "" Then
    strResult = Application.Path & Application.PathSeparator & "STARTUP"
    Dim strMsg As String
    strMsg = "You do not have a STARTUP folder defined."
    strMsg = strMsg & vbCrLf & "Would you like me to set it to """ & strResult & """?"
    Dim intMsg As Integer
    intMsg = MsgBox(strMsg, vbYesNo, "STARTUP folder")
    If intMsg = 6 Then
    ' create the folder and assign it
    Dim strErr As String
    strErr = strMakePath(strResult)
    If strErr = "" Then ' no errors
    Application.StartupPath = strResult
    Else
    Call ReportError("I was unable to create this path: " & strResult)
    End If
    Else
    ' no Startup folder!
    End If
    Else
    End If
    If strResult <> "" Then
    If Right$(strResult, 1) = Application.PathSeparator Then
    Else
    strResult = strResult & Application.PathSeparator
    End If
    Else
    End If
    strGetStartUpFolder = strResult
    'Sub TESTstrGetStartUpFolder()
    ' MsgBox strGetStartUpFolder
    'End Sub
    End Function
    </pre>


  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Save a document using staff number (Word 2000)

    Chris, I don't know about Word 97, but in the modern era, you can ascertain the user's individual WordStartup folder thus:

    strTarget = Options.DefaultFilePath(wdStartupPath)

    I don't know if that always yields the same information as Application.StartupPath (it does for me this morning). Unless you find these properties blank some appreciable amount of the time., I suspect that the above procedure is, indeed, a bit over the top.

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save a document using staff number (Word 2000)

    > the above procedure is, indeed, a bit over the top.

    It does seem that way, but at the time I wrote it - for a self-installing word template package that could end up anywhere, I knew that a user could have an empty StartUp path, so I decided to cater for that case.

    Of course, one I get up to my elbows in nested IF statements, we're all in trouble (grin!)

Posting Permissions

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