Macro for saving in Desktop

ellin00ra

New Member
Joined
Oct 2, 2004
Messages
41
Hi there, everywhere!

I recorded a macro:

Code:
Sub Tallenna()
'
' Tallenna Makro
' ERIM0210 on nauhoittanut makron 23.11.2005.
'

'
    ChDir "C:\Documents and Settings\ERIM0210\Työpöytä"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\ERIM0210\Työpöytä\Kyselylomake.xls", FileFormat:= _
        xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
        , CreateBackup:=False
End Sub

But this should be changed so that when I e-mail the file, the macro saves the file in current user's desktop. Is it even possible?

Thanks, if anyone... :)
 

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

MichaelRo

Well-known Member
Joined
Jun 7, 2004
Messages
549
Try this:

Code:
Sub Tallenna()

Dim StrUserName

StrUserName = Environ("UserName")

    ChDir "C:\Documents and Settings\" & StrUserName & "\Työpöytä"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\" & StrUserName & "\Työpöytä\Kyselylomake.xls", FileFormat:= _
        xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
        , CreateBackup:=False

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,118,458
Messages
5,572,249
Members
412,451
Latest member
newbie22922792
Top