PDA

View Full Version : Solved: Making a macro compatible among multiple users



Lartk
03-08-2013, 10:05 AM
Right now I have the below code that is specific to my desktop. (b/c it has the line ChDir "C:\Users\klartigue\Desktop")


Sub Trades()
' Save blotter
With ActiveSheet
ChDir "C:\Users\klartigue\Desktop"
ActiveWorkbook.Saveas Filename:="C:\Users\klartigue\Desktop\Trades.xls", _
FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

End With

End Sub


Is there a way to generalize C:\Users\klartigue\Desktop so the the document just saves on the desktop of the computer the macro is being run on?

patel
03-08-2013, 11:31 AM
Sub Trades()
With ActiveSheet
user1=Application.UserName
ActiveWorkbook.Saveas Filename:="C:\Users\" & user1 & "\Desktop\Trades.xls", _
FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End With
End Sub

Lartk
03-08-2013, 12:24 PM
That works great, thank you!