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

32/64 Bit Excel VBA Issue with ShellExecute #13

Open
joffemd opened this issue Oct 26, 2012 · 1 comment
Open

32/64 Bit Excel VBA Issue with ShellExecute #13

joffemd opened this issue Oct 26, 2012 · 1 comment

Comments

@joffemd
Copy link
Owner

joffemd commented Oct 26, 2012

Can someone knowledgeable in Excel VBA help us out?

Sone users get compile errors on the following block of code in pscf.xla

If VBA7 Then

Public Declare PtrSafe Function ShellExecute 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 LongPtr

Else

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

End If

...

On Error GoTo 0
Print #1, "locked"
Close #1
Dim args As String
args = arg1 & " " & arg2 & " " & arg3 & " " & arg4 & " " & arg5 & " " & arg6 & " " & arg7
Dim inst As Long
inst = ShellExecute(0, "open", spec, args, work_dir, 0)
If inst <= 32 Then
MsgBox work_dir & ", " & spec
End If
On Error GoTo done:

We need to be able to reliably shell out to Windows under both 32 and 64 bit.

@vishalchowdhary
Copy link
Collaborator

Hi Marc,
I'm not very knowledgable in Excel, but just by looking at the code, it
seems like the following line could cause compile time error due to return
type mismatch:

Dim inst As Long
inst = ShellExecute(0, "open", spec, args, work_dir, 0)

For VBA7, there would be a mismatch between the function return type of
LongPtr vs the variable type Long for inst.

Vishal

On Fri, Oct 26, 2012 at 8:31 AM, Marc Joffe notifications@github.comwrote:

Can someone knowledgeable in Excel VBA help us out?

Sone users get compile errors on the following block of code in pscf.xla

#If VBA7 Then
Public Declare PtrSafe Function ShellExecute 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 LongPtr
#Else
Public Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As
String, ByVal nShowCmd As Long) As Long
#End If

...

On Error GoTo 0
Print #1 #1, "locked"
Close #1 #1
Dim args As String
args = arg1 & " " & arg2 & " " & arg3 & " " & arg4 & " " & arg5 & " " &
arg6 & " " & arg7
Dim inst As Long
inst = ShellExecute(0, "open", spec, args, work_dir, 0)
If inst <= 32 Then
MsgBox work_dir & ", " & spec
End If
On Error GoTo done:

We need to be able to reliably shell out to Windows under both 32 and 64
bit.


Reply to this email directly or view it on GitHubhttps://github.com//issues/13.

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

2 participants