Question for Dave Peterson

J

Jenny B.

Hi Dave,

Earlier this week, you responded to a question I had and I’m wondering if
you can help me once again.

Since I haven’t picked up on this project again until now, I didn’t realize
I made a mistake and the solution you provided me with didn’t quite work like
I thought. I had requested a way to automatically save a copy of the current
user’s workbook page to the desktop without the code being specific (this
will be accessed by multiple users). When I replace SpecialFolders (10) with
SpecialFolders (“Desktopâ€), the file still saves in the same place –
C:\Documents and Settings\Jenny and it’s title is now Desktop and the range
value (not quite correct).

I know I’m just missing just one step to have it placed directly in the
Desktop Folder (so it will appear on my desktop), but I’m not sure how to
accomplish it.

Thank you for your thoughts in advance – Jenny B.
 
D

Dave Peterson

Just a guess.

I'm betting that you're missing a backslash in your code.

Option Explicit
Sub DesktopSave()

Dim myPath As String
Dim nRng As Range
Dim fName As String

Set nRng = ActiveSheet.Range("H5")

ActiveSheet.Copy

myPath = CreateObject("WScript.Shell").SpecialFolders(10)

fName = nRng.Value & ".xls"

ActiveWorkbook.SaveAs Filename:=myPath & "\" & fName, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False

ActiveWorkbook.Close

Call TransfertoLog

Call Clear

End Sub
 
D

Dave Peterson

Ps. it's usually a good idea to post the code (or snippet of code) that's
causing the trouble. That way, potential responders don't have to spend too
much time looking for your old posts.
 
J

Jenny B.

Hi Dave,

Thank you so much. You were exactly right that I was missing a dash and now
it works fine.

Sorry for not providing the original code along with my question. I'm
usually a bit more on the ball, but I forgot and didn't attach it for that
particular post - my apologies

Thanks again and appreciate you taking the time to respond - Jenny B.
 
D

Dave Peterson

Glad you got it working!
Hi Dave,

Thank you so much. You were exactly right that I was missing a dash and now
it works fine.

Sorry for not providing the original code along with my question. I'm
usually a bit more on the ball, but I forgot and didn't attach it for that
particular post - my apologies

Thanks again and appreciate you taking the time to respond - Jenny B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top