Path to my desktops

jbesclapez

Active Member
Joined
Feb 6, 2010
Messages
275
Dear MrExcel,

It is friday, what are you doing for the week end? :biggrin:

I have a more serious question for you.
I would like to use a macro that would open a file in a folder on my desktop. This has to be done with a variable because if i send the folder to a friend, i would like it to work. So the path has to change, right?

Thanks for your help
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
try this
Code:
 Sub testme()
'will open the file Test File
'in a folder on the desktop named New Folder
    Dim WSHShell As Object
    Dim DesktopPath As String
    
    Set WSHShell = CreateObject("WScript.Shell")
    DesktopPath = WSHShell.SpecialFolders("Desktop")
    Set WSHShell = Nothing
    
    Workbooks.Open Filename:= _
        DesktopPath & "\New Folder\Test File.xls"
End Sub
 
Upvote 0
Thanks a lot! It is EXACTLY what i was looking for. So i presume my question was good :)

Just to know Sir : How long time did it take you to find or create this piece of code? I am just (too) curious.

However. Thanks again.
 
Upvote 0
Your Welcome
I needed to do something like this before, found the code somewhere but don't remember where.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,733
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top