Hi all.
I am currently in the process of migrating my organization from V8i to Connect. This includes the VBA that have been written over the years, most have been a non issue but there are some that used the Ken Getz code to call the cmdlg32.dll api to open and process a file, that draws out a bridge plot based on an in house geometry. I have gone through an added the needed PtrSafe to the declare function:
Declare PtrSafe Function aht_apiGetOpenFileName Lib "comdlg32.dll" _ Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean
I have gone through and changed the declaration of tagOPENFILE name to:
Type tagOPENFILENAME lStructSize As Long hwndOwner As LongPtr hInstance As LongPtr lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As LongPtr lpTemplateName As StringEnd Type
I have gotten the program to run and not crash. But it fails to open the called dialog box. I have tried every different option I came across in my searches and nothing has worked. If anyone has another method to call an open file dialog in VBA or any suggestion on getting this to work it would be appreciated. My other option is to convert this program to .Net
Hi,
dbholman said:Declare PtrSafe Function aht_apiGetOpenFileName Lib "comdlg32.dll"
MicroStation CONNECT Edition is 64bit program, so also VBA is 64bit. It means you cannot use 32bit dlls.
dbholman said:My other option is to convert this program to .Net
To rewrite program to NET is probably good ide in general is good idea, but it requires to rewrite the code, because new NET API is very different. It's still possible to use classic Interop API, which is quite the same as VBA API, but in my opinion it makes no sense when the code is rewritten to use old API.
But what should be possible is to use MDL functions (it was possible also in V8i) and not Windows dll files. There is mdlDialog_fileOpen function that is available both in V8i and CONNECT Edition. Maybe it's enough for what you need.
Unfortunately I have no code example, so you will have to do own research how to call this function from VBA.
Another alternative is to try to find 64bit OCX / DLL library that provides Windows dialogs access.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point