User ID VBA not working.

XJOutsider
05-20-2010, 03:07 PM
I have a macro I am using to save a file to the user Desktop in a specific Folder.


Dim LDate As String
LDate = Date
Dim USERID As String
USERID = Environ("username")'us this to complete the path with there profile id.
wsPOMGR.SaveAs "C:\Profiles\USERID\Desktop\MRPScreen\Pomanager" & _
Format(Date, "MMDDYYYY") & ".xlsm", FileFormat:=52


What it looks like with my id hard coded into it.

Dim LDate As String
LDate = Date

wsPOMGR.SaveAs "C:\Profiles\mktstq\Desktop\MRPScreen\Pomanager" & _
Format(Date, "MMDDYYYY") & ".xlsm", FileFormat:=52



When I look in the locals it shows USERID as "mktstq"

What am I am doing wrong?

Colin Legg
05-21-2010, 02:11 AM
Hi,

You need to concatenate the USERID variable with the rest of the string, as you did with the Format() function, ie

wsPOMGR.SaveAs "C:\Profiles\" & USERID & "\Desktop\MRPScreen\Pomanager" & _
Format(Date, "MMDDYYYY") & ".xlsm", FileFormat:=52

XJOutsider
05-24-2010, 10:51 AM
Thanks Collin

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum