OlimilO1402 / Win_Dialogs

VBC+VBA7, x86+x64, Unicode, windows common dialogs, Color-, Font-, OpenFile-, SaveFile-, OpenFolder-Dialog, MessageBox
GNU General Public License v3.0
15 stars 4 forks source link

Printer Dialog #5

Open KallunWillock opened 1 month ago

KallunWillock commented 1 month ago

It may be the case that this is a known issue, but PrinterDlg.XLSM does not appear to work as-is for VBA 64-bit.

It seems to me that the issue arises from using the hInstance property for the Application object in the _ApphInstance function. Excel 64-bit, example, has the hInstancePtr property, and using that instead gets the code working (as below). I have had to change the VBA complier constant to VBA7, and I don't think that 32-bit will make sense of the app variable, so that would need to be addressed too.

Private Function App_hInstance() As LongPtr
#If VBA7 Then
    App_hInstance = Excel.Application.HinstancePtr
#Else
    App_hInstance = app.hInstance
#End If
End Function
OlimilO1402 commented 1 month ago

Thanks for reporting the issue, unfortunately the code does not seem to work either way, on my machine now. Not in VB6 and not in excel vba7. What windows-version do you have?

KallunWillock commented 1 month ago

Hmm, that's strange. I'll check with others to see if the change above gets it working for them. I'm using Windows 11, MS365 64-bit (Excel) and by changing it to HInstancePtr as above, it worked for me.

image

OMIBPuhla commented 1 month ago

Of course your suggestion is 100% correct. There never was a compiler constant, called "VBA". For VBA-users before "VBA7" (before 2007) there was the compiler constant "VBA6". But I do not know if the hInstancPtr-property did already exist, back then.

KallunWillock commented 1 month ago

Of course your suggestion is 100% correct. There never was a compiler constant, called "VBA". For VBA-users before "VBA7" (before 2007) there was the compiler constant "VBA6". But I do not know if the hInstancPtr-property did already exist, back then.

You're right, there wasn't a hInstancePtr property - I believe that was introduced with 64bit Office. 64bit Office still has the hInstance property, but it doesn't return a value. I thought VBA6 might be the correct compiler constant, but wasn't sure. I did adjust the code above, and meant to post it with the image, but it slipped my mind, I'm sorry:

Private Function App_hInstance() As LongPtr
  #If VBA7 Then
    App_hInstance = Excel.Application.HinstancePtr
  #ElseIf VBA6 Then
    App_hInstance = Excel.Application.hInstance
  #Else
    App_hInstance = app.hInstance
  #End If
End Function
OlimilO1402 commented 1 month ago

@KallunWillock, in the meanwhile please consider starring the repo

KallunWillock commented 1 month ago

I'm sorry, I genuinely thought I had. It turns out I had accidenrally starred one of your other repos. :-)

OlimilO1402 commented 1 month ago

many thanks, starring doesn't hurt :-) btw why is your dialog in excel "themed"?

KallunWillock commented 1 month ago

Oh I don't know. What do you mean exactly? The screen capture of the print dialogue above? Whatever the case, knowing me, there won't be a particularly intelligent reason behind whatever it is I've done!

On Tue, 24 Sep 2024, 7:03 pm OlimilO1402, @.***> wrote:

many thanks, starring doesn't hurt :-) btw why is your dialog in excel "themed"?

— Reply to this email directly, view it on GitHub https://github.com/OlimilO1402/Win_Dialogs/issues/5#issuecomment-2371959238, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF6BQMZQKCAO5HZQ44OXFPLZYGSQFAVCNFSM6AAAAABOUY6Y3SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZRHE2TSMRTHA . You are receiving this because you were mentioned.Message ID: @.***>

OlimilO1402 commented 1 month ago

yeah your screen capture, I am not sure, maybe it is because you have latest Office on Win 11. I encountered a surprise, in VB6 now we get a WinUI-ish-printdialog see the last screenshot https://github.com/OlimilO1402/Win_Dialogs/blob/main/Resources/Pictures/PrintDialogWinUI.png