Hello,
I'm relatively new to using VBA to generate and save files, but these forums have proved such good help that I've only had to sign up for an account now, as I've found no solution to my problem. Please forgive me for any impolitic behaviour, with respect to posting rules in this forum.
I am running 32-bit Excel 2007 with VBA 6.5 on work Windows 7 machines and 64-bit Excel 2013 with VBA 7.1 on my home Windows 8 machine. I have pieced together a folder-browsing Function that selects, by default, the folder location that has already been stored. I have set this up so that it works on both machines with IF WIN64 blocks and the function works properly in both circumstances, for the most part.
My issues are that (1) pressing Esc yields the "Code execution has been interrupted" error message, and (2) double clicking on a folder that has no sub-folders is not recognized as selecting it. This is the same in both versions.
The line of code that is highlighted after the error message is always the line after the call to the SHBrowseForFolder function (see below). I have tried inputing return-value checks and error handling to no avail. Is this a limitation of the shell32 function SHBrowseForFolder function, or does anyone know of any way around this?
Any advice is much appreciated.
Kurt
Declarations:
...
Function:
I'm relatively new to using VBA to generate and save files, but these forums have proved such good help that I've only had to sign up for an account now, as I've found no solution to my problem. Please forgive me for any impolitic behaviour, with respect to posting rules in this forum.
I am running 32-bit Excel 2007 with VBA 6.5 on work Windows 7 machines and 64-bit Excel 2013 with VBA 7.1 on my home Windows 8 machine. I have pieced together a folder-browsing Function that selects, by default, the folder location that has already been stored. I have set this up so that it works on both machines with IF WIN64 blocks and the function works properly in both circumstances, for the most part.
My issues are that (1) pressing Esc yields the "Code execution has been interrupted" error message, and (2) double clicking on a folder that has no sub-folders is not recognized as selecting it. This is the same in both versions.
The line of code that is highlighted after the error message is always the line after the call to the SHBrowseForFolder function (see below). I have tried inputing return-value checks and error handling to no avail. Is this a limitation of the shell32 function SHBrowseForFolder function, or does anyone know of any way around this?
Any advice is much appreciated.
Kurt
Declarations:
Code:
Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpbi As BrowseInfo) As Long
Private Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
...
Function:
Code:
Dim lpIDList As Long
Dim tBrowseInfo As BrowseInfo
...
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
...