Solved

Word 2000 Macro

Posted on 2007-11-20
3
252 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
3 Comments
 
LVL 8

Accepted Solution

by:
Galisteo8 earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now