
Originally Posted by
DMT Dave
@ moke123, when you say standard module, do you mean within the same module as the sub ie: paste above the Private Sub or create a mod then call it ?
I tried your post and comes back vriable not defined even with option explicit declared in the mod. that was pasted into Publuc Functions module, not the local module (above teh sub)
Put it in it's own module or just import the module in the attached example.
The three module types are
Form Module ( a class module)
Class Module ( a class module for custom classes)
Standard Module
As far as your error, my guess is that you didn't have the following part of the code at the top of the module:
Code:
#If Win64 Then 'Public Dclare PtrSafe Function
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
Private Declare PtrSafe Function GetDesktopWindow Lib "user32" () As Long
#Else
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
#End If
Const SW_SHOWNORMAL = 1
Const SE_ERR_FNF = 2&
Const SE_ERR_PNF = 3&
Const SE_ERR_ACCESSDENIED = 5&
Const SE_ERR_OOM = 8&
Const SE_ERR_DLLNOTFOUND = 32&
Const SE_ERR_SHARE = 26&
Const SE_ERR_ASSOCINCOMPLETE = 27&
Const SE_ERR_DDETIMEOUT = 28&
Const SE_ERR_DDEFAIL = 29&
Const SE_ERR_DDEBUSY = 30&
Const SE_ERR_NOASSOC = 31&
Const ERROR_BAD_FORMAT = 11&