N
Nick Ward
Hi
I pulled this script to open a fireworks file from a command in my database from an O'reilly Access Cookbook. It works well excepting the fact that it refuses to work if their are spaces in the any of the directory names that the file reside in. It would be a real pain to have to rename all associated directories as I have so many links to files within them already, so I was wondering if any one had any ideas as to how to overcome this issue
TIA
Declare Function acb_apiFindExecutable Lib "shell32" Alias "FindExecutableA" _
(ByVal strFile As String, ByVal strDirectory As String, ByVal strResult As String) As Long
Declare Function acb_apiShellExecute Lib "shell32" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal strOperation As String, ByVal strFile As String, _
ByVal strParameters As String, ByVal strDirectory As String, ByVal lngShowCmd As Long) As Long
Public Const acbcMaxPath = 160
Public Const acbSW_HIDE = 0
Public Const acbSW_SHOWNORMAL = 1
Public Const acbSW_NORMAL = 1
Public Const acbSW_SHOWMINIMIZED = 2
Public Const acbSW_SHOWMAXIMIZED = 3
Public Const acbSW_MAXIMIZE = 3
Public Const acbSW_SHOWNOACTIVATE = 4
Public Const acbSW_SHOW = 5
Public Const acbSW_MINIMIZE = 6
Public Const acbSW_SHOWMINNOACTIVE = 7
Public Const acbSW_SHOWNA = 8
Public Const acbSW_RESTORE = 9
Const acbcHInstanceErr = 32
Function acbFindExecutable(strFile As String, strDir As String, strResult As String)
' Find the executable file associated with a given
' data file. Return the value returned from the
' call to FindExecutable. This function just
' acts as a wrapper to FindExecutable, dealing with
' the null character removal.
Dim strBuffer As String
Dim intRetval As Integer
strBuffer = Space(acbcMaxPath)
strResult = ""
intRetval = acb_apiFindExecutable(strFile, strDir, strBuffer)
If intRetval > acbcHInstanceErr Then
strResult = TrimNull(strBuffer)
End If
acbFindExecutable = intRetval
End Function
Private Function TrimNull(strValue As String)
' Trim strValue at the first
' null character you find.
Dim intPos As Integer
intPos = InStr(strValue, vbNullChar)
If intPos > 0 Then
TrimNull = Left$(strValue, intPos - 1)
Else
TrimNull = strValue
End If
End Function
'******************************************************************************
Public Const library_items As String = "Library_items.png"
Public Const Library_local As String = "C:\Main_png_library"
However if the file was located in "C:\Main png library" it wouldn't work
Public Function open_library()
' opens the library png file in fireworks to create a new seating plan
Dim intRetval As String
Dim strBuffer As String
intRetval = acbFindExecutable(Library_local & library_items, ".", strBuffer)
intRetval = acb_apiShellExecute(1, "open", strBuffer, library_items, Library_local, acbSW_SHOWMAXIMIZED)
End Function
I pulled this script to open a fireworks file from a command in my database from an O'reilly Access Cookbook. It works well excepting the fact that it refuses to work if their are spaces in the any of the directory names that the file reside in. It would be a real pain to have to rename all associated directories as I have so many links to files within them already, so I was wondering if any one had any ideas as to how to overcome this issue
TIA
Declare Function acb_apiFindExecutable Lib "shell32" Alias "FindExecutableA" _
(ByVal strFile As String, ByVal strDirectory As String, ByVal strResult As String) As Long
Declare Function acb_apiShellExecute Lib "shell32" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal strOperation As String, ByVal strFile As String, _
ByVal strParameters As String, ByVal strDirectory As String, ByVal lngShowCmd As Long) As Long
Public Const acbcMaxPath = 160
Public Const acbSW_HIDE = 0
Public Const acbSW_SHOWNORMAL = 1
Public Const acbSW_NORMAL = 1
Public Const acbSW_SHOWMINIMIZED = 2
Public Const acbSW_SHOWMAXIMIZED = 3
Public Const acbSW_MAXIMIZE = 3
Public Const acbSW_SHOWNOACTIVATE = 4
Public Const acbSW_SHOW = 5
Public Const acbSW_MINIMIZE = 6
Public Const acbSW_SHOWMINNOACTIVE = 7
Public Const acbSW_SHOWNA = 8
Public Const acbSW_RESTORE = 9
Const acbcHInstanceErr = 32
Function acbFindExecutable(strFile As String, strDir As String, strResult As String)
' Find the executable file associated with a given
' data file. Return the value returned from the
' call to FindExecutable. This function just
' acts as a wrapper to FindExecutable, dealing with
' the null character removal.
Dim strBuffer As String
Dim intRetval As Integer
strBuffer = Space(acbcMaxPath)
strResult = ""
intRetval = acb_apiFindExecutable(strFile, strDir, strBuffer)
If intRetval > acbcHInstanceErr Then
strResult = TrimNull(strBuffer)
End If
acbFindExecutable = intRetval
End Function
Private Function TrimNull(strValue As String)
' Trim strValue at the first
' null character you find.
Dim intPos As Integer
intPos = InStr(strValue, vbNullChar)
If intPos > 0 Then
TrimNull = Left$(strValue, intPos - 1)
Else
TrimNull = strValue
End If
End Function
'******************************************************************************
Public Const library_items As String = "Library_items.png"
Public Const Library_local As String = "C:\Main_png_library"
However if the file was located in "C:\Main png library" it wouldn't work
Public Function open_library()
' opens the library png file in fireworks to create a new seating plan
Dim intRetval As String
Dim strBuffer As String
intRetval = acbFindExecutable(Library_local & library_items, ".", strBuffer)
intRetval = acb_apiShellExecute(1, "open", strBuffer, library_items, Library_local, acbSW_SHOWMAXIMIZED)
End Function