Hi,
Thanks for your help. The Declare statements I used came directly from the Win32API_PrtSafve text file.
To show you what I am referring to here is Microsoft's general information on this issue:
https://learn.microsoft.com/en-us/office/troubleshoot/office-suite-issues/win32api_ptrsafe-with-64-bit-support
This webpage also has a link to where you can download the Win32APUI-PrtSafe with 64-bit Support text file. That is where I got the file from. When you run the installer after downloading the file form the link, it does not tell you where it installed the information. Look in this -new- folder on your C drive:
C:\Office 2010 Developer Resources\Documents\Office2010Win32API_PtrSafe
If I am reading this correctly, the Declare statement related to GetSaveFileName in the Win32API_PrtSafe.txt file contains updated declarations and types. Of course, they could also be wrong. I am not sure if it is a bug. But I would hope they are correct.
The GetSaveFileName as described in Win32API_PrtSafe refers to Lib "comdlg32.dll" which is why I didn't change it to something like Lib "comdlg64.dll"
The only thing I didn't do was include the last 3 items in the type definition as I don't use them. Including them also didn't resolve the problem. Just to clarify here are those 3 items which I copied from the Win32API_PrtSafe.txt file. As a second test, I also used a Win API Viewer that showed the same thing.
'#if (_WIN32_WINNT >= 0x0500)
pvReserved As LongPtr
dwReserved As Long
FlagsEx As Long
'#endif // (_WIN32_WINNT >= 0x0500)
End Type
I also looked at the webpage
https://social.msdn.microsoft.com/Forums/en-US/1db77ef4-f363-4e60-b680-6cf1c44e22bd/office-32bit-vs-64bit-comdlg32dll
and the declarations are the same except mine are marked as private instead. If I delete the Private attribute, I get the following compile error (32-bit office):
"Compile error: Private Enum and user defined types cannot be used as parameters or return types for public procedures, public data members, or fields of public user defined types."
That is why I added the attribute Private to my Declares i.e. scope.
Anyway, to get back to my original question, I still don't know why or what is the cause of the error code 1 that is being returned from the call to the API CommDlgExtendedError (on 64-bit Office; this does not occur on a computer with 32-bit Office)
Here is more information on what I have read about the API CommDlgExtendedError. Again, just providing it to show you what I believe is the main problem:
http://www.jasinskionline.com/WindowsApi/ref/c/commdlgextendederror.html
And the error as described on this webpage was:
CDERR_STRUCTSIZE = &H1
The function was provided with an invalid structure size
I am not completely sure what the ampersand or the H stand for before the number 1 but I am guessing 1 (as a decimal) is the same &H1 (guessing hexadecimal).
Does this seem to be on the right track or I could be mistaken.
Of course, it could be something I am overlooking. Just remember I already used LenB function on the following line of code.
With OpenFile
.lStructSize = LenB(OpenFile)
This was similar to another user who had the same problem I am having but in that case the solution was:
"Try using sizeof (OPENFILENAME) for the lStructSize member"
The closest thing in VBA7 (in Access 2010) is using the LenB function. VBA7 started with Office 2010.
By the way, this webpage on the GetSaveFileName API also uses Len but not LenB. Either way, it doesn't seem to resolve my problem:
http://www.jasinskionline.com/WindowsApi/ref/g/getsavefilename.html
I also tried adding the following 2 items and the fields in the type to see if it worked after adding it to my type definition:
.lCustData = 0
.lpfnHook = 0
It still doesn't work on the Office 64-bit machine but it does work as it always has been on the Office 32-bit machine. Error code 1 is still being returned by the call to the API CommDlgExtendedError.
This is what I believe is the problem. I just don't know how to resolve it on the 64-bit office computer.
Anyway, thanks again. Just wanted to give an update.