我一直在尝试使用VBA代码从Excell打开一个模板,最后得到了下面的代码为我工作。
唯一的问题是它会打开模板文件两次。
有人知道为什么会这样吗?
干杯
上下快速移动
- Option Explicit
- Declare Function ShellExecute Lib "shell32.dll" _
- Alias "ShellExecuteA" ( _
- ByVal hWnd As Long, _
- ByVal lpOperation As String, _
- ByVal lpFile As String, _
- ByVal lpParameters As String, _
- ByVal lpDirectory As String, _
- ByVal nShowCmd As Long) As Long
- Function OpenAnyFile(FileToOpen As String)
-
- Call ShellExecute(0, "Open", FileToOpen & vbNullString, _
- vbNullString, vbNullString, 1)
-
- End Function
- Sub Example()
-
- Call OpenAnyFile("I:\Support\Drafting\Drawing Templates\Skid.dwt")
-
- End Sub
|