Workbooks.Open Filename:="C:\Desktop\VBA\Phase 1\A.xlsx"
如何从桌面或任何用户的文档中打开文件。
答案 0 :(得分:1)
您可以通过多种方式选择适合您的方式 -
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