64 bit code compiles but wont work (1 Viewer)

Dreamweaver

Well-known member
Local time
Today, 19:57
Joined
Nov 28, 2005
Messages
2,466
As I was testing a download on my Mrs 64 bit access system I thought I would look as making it compatable and after removing a As LongPtr and changing for As Long
The arrow shows where you need to remover the Ptr from mdlShellExecute
Code:
#If VBA7 Then
    Private Declare PtrSafe Function apiShellExecute Lib "Shell32.dll" _
    Alias "ShellExecuteA" _
    (ByVal hWnd As LongPtr, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) _
    As Long  <----
#Else

It compiled but when I try using both the colour chooser and the Commondialog code wont work

 

vba_php

Forum Troll
Local time
Today, 14:57
Joined
Oct 6, 2019
Messages
2,884
As I was testing a download on my Mrs 64 bit access system I thought I would look as making it compatable and after removing a As LongPtr and changing for As Long
The arrow shows where you need to remover the Ptr from mdlShellExecute
Code:
#If VBA7 Then
    Private Declare PtrSafe Function apiShellExecute Lib "Shell32.dll" _
    Alias "ShellExecuteA" _
    (ByVal hWnd As LongPtr, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) _
    As Long  <----
#Else
what kind of code is that, Mick? What's the "#" symbol for? I've never used it. is that a comment? Is that DOS code? I believe "#" is used in DOS batch files. what are you doing with this code anyway? what's it supposed to do? You say "it compiled", which means it's not a batch file, but rather vba code, right? What do you mean by this?
It compiled but when I try using both the colour chooser and the Commondialog code wont work
what colour chooser? a form control? what's "commonDialog" mean? the FSO in VBA? a file dialog from windows in VBA? You should also note that the whole phenomenon of 32-bit windows VS. 64-bit windows, and 32-bit office VS. 64-bit office is littered with uncertainties, which I believe are totally undocumented by Microsoft, which unfortunately makes sense. I've had to go in many times and modify VBA code after switching from 32-bit windows to 64-bit windows because the API function declaration code was erroring out in many places. as a point of research, did you try to investigate this possible solution to your DLL reference?

https://www.google.com/search?q=Shell32.dll+in+64+bit+windows. If I'm not misaken, Shell32.dll belongs to windows, not access.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:57
Joined
Oct 29, 2018
Messages
21,358
Hi Mick. Here's the proper declaration for 64-bit ShellExecute. That should have been a LongPtr. I am not sure what you were trying to do. Were you trying to add a declaration for 32-bit? If so, you would do it in the #Else part. Also, if you're saying this is not working on a 64-bit machine, then it's possible you're trying to use an ActiveX control that is 32-bit. If so, you'll need to find a 64-bit version of it/them. Good luck!
 

isladogs

MVP / VIP
Local time
Today, 19:57
Joined
Jan 14, 2017
Messages
18,186
Adam
Once again you are posting where you know nothing about the subject.
As a result much of your answer was incorrect.
Why do you continue to do this?
So you can do some research yourself, the #If VBA7 part is used in conditional compilation to manage 32/64-bit conversion

Mick
If you were referring to the old CommonControls reference, that doesn't work in 64-bit Office and is no longer supplied with Win10.
Due to that, I stopped using it some time ago
For example, see this thread Logged In Users
I have heard that a 64-bit version has recently been released but I haven't looked for it

Also, if it helps, I have code for a colour chooser that works in both 32-bit & 64-bit here: Colour Conditions
 

vba_php

Forum Troll
Local time
Today, 14:57
Joined
Oct 6, 2019
Messages
2,884
i'm sorry Colin. you can delete it if it was out of line. don't hesitate to do so. I'll try to improve.
 

isladogs

MVP / VIP
Local time
Today, 19:57
Joined
Jan 14, 2017
Messages
18,186
Its not so much out of line as unhelpful
If you accept my point, you can delete it yourself
 

Dreamweaver

Well-known member
Local time
Today, 19:57
Joined
Nov 28, 2005
Messages
2,466
@isladogs Thanks I'll try your colour choose
@theDBguy I was using Longptr but it wouldn't complile once I changed it it compliled

I'll see if I can borrow my Mrs Laptop tomorrow and see make the changes

P.S. For my accde's I now use total visual source for all my API's

many thanks for the help

mick
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:57
Joined
Oct 29, 2018
Messages
21,358
@isladogs Thanks I'll try your colour choose
@theDBguy I was using Longptr but it wouldn't complile once I changed it it compliled

I'll see if I can borrow my Mrs Laptop tomorrow and see make the changes

P.S. For my accde's I now use total visual source for all my API's

many thanks for the help

mick
Hi Mick. Just to clarify a bit, if you're trying to compile the above on a 32-bit Access machine, the #VBA7 part should show up in red, as if there's a syntax error. That's normal. When you say "it won't compile," I assume you mean by going to Debug > Compile ProjectName. If so, the compiler directives should only execute/compile the appropriate branch depending on if Access is 32- or 64-bit. So, if you were referring to seeing a red font, I say don't worry about it.

Sent from phone...
 

isladogs

MVP / VIP
Local time
Today, 19:57
Joined
Jan 14, 2017
Messages
18,186
Sorry DBG but that's not quite correct
Conditional compilation code will only show in RED where it is not valid

In A2010 or later, the #If VBA7 part is valid in both 32-bit & 64-bit, so ALWAYS appears in BLUE
However that part will appear in RED in A2007 or earlier as VBA6 doesn't recognise PtrSafe or LongPtr
Similarly the #Else part will show in RED in 64-bit Access as that requires the use of PtrSafe & LongPtr

The fact that VBA7 code works in both bitnesses is why conditional compilation can be dispensed with if all users run A2010 or later
 

vba_php

Forum Troll
Local time
Today, 14:57
Joined
Oct 6, 2019
Messages
2,884
Colin,

I have a little more to say on this subject. I want you and all your mod friends to know why exactly I post these types of things in threads like this. In this (Mick's) case, I saw the thread appear in the "unanswered threads" URL and it was like 3 hours old or something. So when I see something like that, this is my first thought:
hmmmm....well maybe the experts are too busy or don't know the answer, so maybe I can say a few things that might spark an idea or give them an extra piece of information they can use or add to their knowledgebase
If that is my intention, what's wrong with that? Referring to my 1st post in this thread, I would assume that Mick could of gotten something from this, even if it's a spec of dust (I should've said more, I admit, in terms of elaboration):
I've had to go in many times and modify VBA code after switching from 32-bit windows to 64-bit windows because the API function declaration code was erroring out in many places
I do remember a few instances in the past 3 months under this username where some of the *experts* here have blatently said to me, after my efforts to contribute in a given thread:
you're way off base, like usual
and others too were posted, with different text but the purpose was still the same. In terms of me posting first in threads like this, where they go answered for hours until I say something, I've noticed a pattern with it in terms of what happens after my post. I won't belabor what I've seen happen because it's not worth mentioning, but that pattern is just one of many I see go on here on the forum and in my encounters in real life.

I know, because they've told me, that some *experts* here believe I know nothing about anything, and that doesn't bother me but I do think that's the most ridiculous thing I've ever heard. It just so happens that, I have just moved into a position of managing a team of 10 people. So apparently I must know *something*, otherwise I wouldn't be doing what I'm now doing. But to the point, or back to it, I want to let you know that the reason I post initially in threads like this, per my quote above regarding what I'm thinking, is so that, the person reading my suggestions can:

=> get *something* from it, whether it be advice, a spark of curiosity, a piece of knowledge previously unknown to them, or an actual piece of code.
=> use that receipt to increase their "bag of tricks" and "knowledgebase", so they have the confidence and courage to go out and build software on their own.
=> and then of course, if what they got was a "spark of curiosity", come back here to ask more questions because they're interested in doing more with what they've acquired.

so there ya go Colin, what's wrong with that method? Can you honestly say that my 1st post here provided absolutely *nothing* in terms of knowledge or resources? If you say YES, I'll heed the words and stop doing stuff like it, just like I told Doc I would stop calling him ''grandpa''. Just say the word, man.
 

isladogs

MVP / VIP
Local time
Today, 19:57
Joined
Jan 14, 2017
Messages
18,186
Adam
OK you asked...so I'll be blunt ... though I've said all the following before on more than one occasion both privately and publicly.

When I don't know the answer to a question, I don't respond to a thread. If the topic interests me, I read and hopefully learn for next time.
As many people here have said on numerous occasions, you should do the same.

You post offered nothing of value to the OP who clearly knows far more about the subject than you do.
So none of your list of reasons are valid. Indeed they could be seen as condescending.

Also because most of it was irrelevant or disinformation, nor would any of your answer be helpful to other members or guests who come across this thread. Please stick to topics you do know something about so other members aren't put into the position of having to correct you.
 

vba_php

Forum Troll
Local time
Today, 14:57
Joined
Oct 6, 2019
Messages
2,884
As many people here have said on numerous occasions, you should do the same.
OK. I'll do my best to recognize when I'm starting to post something that is nothing of value.
 

Users who are viewing this thread

Top Bottom