Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printer Dialog #5

Open
KallunWillock opened this issue Sep 22, 2024 · 9 comments
Open

Printer Dialog #5

KallunWillock opened this issue Sep 22, 2024 · 9 comments

Comments

@KallunWillock
Copy link

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 App_hInstance 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
Copy link
Owner

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
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link
Owner

@KallunWillock, in the meanwhile please consider starring the repo

@KallunWillock
Copy link
Author

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

@OlimilO1402
Copy link
Owner

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

@KallunWillock
Copy link
Author

KallunWillock commented Sep 25, 2024 via email

@OlimilO1402
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants