Reputation: 201
Workbooks.Open Filename:="C:\Desktop\VBA\Phase 1\A.xlsx"
How do I open the file from desktop or documents of any user.
Upvotes: 1
Views: 4925
Reputation: 12499
Multiple ways you can do that, pick the one that works for you-
Option Explicit
Public Sub Example()
Dim FilePath As String
FilePath = CreateObject("WScript.Shell") _
.specialfolders("Desktop") & "\VBA\Phase 1\A.xlsx"
Debug.Print FilePath
End Sub
Option Explicit
Public Sub Example2()
Dim FilePath As String
FilePath = Environ("USERPROFILE") & "\Desktop\VBA\Phase 1\A.xlsx"
Debug.Print FilePath
End Sub
Upvotes: 3