Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Word 2000 Macro

Posted on 2007-11-20
3
Medium Priority
?
260 Views
Last Modified: 2010-04-24
Hi,
I wrote the following Macro in Word and added it as a button on the toolbar so that when any user connects to our Terminal Server and runs Word, they can save the current document to their local C:\.

ChangeFileOpenDirectory "\\tsclient\C\"
ActiveDocument.Save

This works fine, but it would be ideal to save the document to the users local My Documents folder. To do that requires a variable and I need help with that. I tried this but it doesn't work:

ChangeFileOpenDirectory "\\tsclient\C\Documents and settings\%UserProfile%\My Documents\"
ActiveDocument.Save

I think I'm on the right track, just need the correct variable for the current user, and proper syntax.

Thanks,
Bill
0
Comment
Question by:westone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
Galisteo8 earned 2000 total points
ID: 20320415
Hi, Bill,

This might be what you're looking for:
http://word.mvps.org/faqs/MacrosVBA/GetCurUserName.htm

Once you've got the function in your code, you should be able to call it like this:

ChangeFileOpenDirectory "\\tsclient\C\Documents and settings\" & GetUserName & "\My Documents\"
ActiveDocument.Save


hth,
Galisteo8
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20320433
You can use Environ

Sub SetFolderFromEnviron()
    Dim i As Integer
    Dim env() As String
   
    Do
        i = i + 1
        env = Split(Environ(i), "=")
        If UCase$(env(0)) = "USERNAME" Then
            ChangeFileOpenDirectory "\\tsclient\C\Documents and settings\" & env(1) & "\My Documents\"
            ActiveDocument.Save
            Exit Sub
        End If
    Loop Until UBound(env) < 1
   
    MsgBox "UserName not found"

End Sub
0
 

Author Closing Comment

by:westone
ID: 31410104
Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question