Bobkat Posted November 30, 2012 Posted November 30, 2012 (edited) I have been trying to open a template from Excell using VBA code and finally got the code below to work for me. Only problem is that it opens the template file twice. Can anyone see why it woulf be doing that? Cheers Bob 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 Edited December 1, 2012 by Bobkat Oops, that better? Quote
SLW210 Posted November 30, 2012 Posted November 30, 2012 Bobkat, Please read the CODE POSTING GUIDELINES and edit your post to include Code Tags. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.