vba - ShellExecute brings Office programs to crash -
i used printout pdf-files ms access 2010 32-bit on windows 7 32 bit code.
declare function shellexecute lib "shell32.dll" alias "shellexecutea" (byval hwnd long, byval lpoperation string, byval lpfile string, byval lpparameters string, byval lpdirectory string) long function printattachement() shellexecute 0, "print", "\\s1016d\attachments\40297827.pdf", "", "" end function
now, changed windows 7 64 bit, still office 32 bit , office applications crashes when running function.
strange, because if use "open" iso. "print" works expected!
please help, lost how correct function run again.
all want printout pdf-file access without opening file. there many files in row, cannot open pdf-app printout file.
thanks michael
edit: after long searches found solution!
you have declare function in 64bit application, make shure run on machines 32bit declare both.
#if vba7 private declare ptrsafe function shellexecute lib "shell32.dll" alias "shellexecutea" _ (byval hwnd long, byval lpoperation string, byval lpfile string, byval lpparameters string, byval lpdirectory string, byval nshowcmd long) long
else
private declare function shellexecute lib "shell32.dll" alias "shellexecutea" _ (byval hwnd long, byval lpoperation string, byval lpfile string, byval lpparameters string, byval lpdirectory string, byval nshowcmd long) long
end if
so in order show answered, , vouch solve same situation me. if referencing windows dll in-line, need ensure correct dll being used based on environment access db being used in (32bit vs 64bit) can dynamically described above (and repeated here)
#if vba7 private declare ptrsafe function apishellexecute lib "shell32.dll" _ alias "shellexecutea" _ (byval hwnd long, _ byval lpoperation string, _ byval lpfile string, _ byval lpparameters string, _ byval lpdirectory string, _ byval nshowcmd long _ ) long #else private declare function apishellexecute lib "shell32.dll" _ alias "shellexecutea" _ (byval hwnd long, _ byval lpoperation string, _ byval lpfile string, _ byval lpparameters string, _ byval lpdirectory string, _ byval nshowcmd long _ ) long #end if
Comments
Post a Comment