Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to get code I found on the net to run - I need to open a
DOS command window (to run PDFTK) I get a compile error: Sub or Function not defined. I've tried putting the full path to kernel32. Do I need add some 'References' - at the moment I have vba. excel 11.0, ole automation. office 11.0 Here are is the bit of code that won't run: Option Explicit Private Declare Function CloseHandle Lib "kernel32" ( _ ByVal hObject As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" ( _ ByVal hProcess As Long, lpExitCode As Long) As Long Private Declare Function OpenProcess Lib "kernel32" ( _ ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Public Function ShellX( _ ByVal PathName As String, _ Optional ByVal WindowStyle As VbAppWinStyle = vbMinimizedFocus, _ Optional ByVal Events As Boolean = True _ ) As Long 'Declarations: Const STILL_ACTIVE = &H103& Const PROCESS_QUERY_INFORMATION = &H400& Dim ProcId As Long Dim ProcHnd As Long 'Get process-handle: ProcId = Shell(PathName, WindowStyle) ProcHnd = OpenProcess(PROCESS_QUERY_INFORMATION, True, ProcId) 'wait for process end: Do If Events Then DoEvents GetExitCodeProcess ProcHnd, ShellX Loop While ShellX = STILL_ACTIVE 'clean up: CloseHandle ProcHnd End Function Sub testdunno() Dim x As Long x = ShellX("pdftk a.pdf cat 1-endodd output b.pdf") Beep ' done End Sub Thanks Oliver |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It compiles for me... What is it saying is not defined...
-- HTH... Jim Thomlinson "oliver" wrote: I'm trying to get code I found on the net to run - I need to open a DOS command window (to run PDFTK) I get a compile error: Sub or Function not defined. I've tried putting the full path to kernel32. Do I need add some 'References' - at the moment I have vba. excel 11.0, ole automation. office 11.0 Here are is the bit of code that won't run: Option Explicit Private Declare Function CloseHandle Lib "kernel32" ( _ ByVal hObject As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" ( _ ByVal hProcess As Long, lpExitCode As Long) As Long Private Declare Function OpenProcess Lib "kernel32" ( _ ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Public Function ShellX( _ ByVal PathName As String, _ Optional ByVal WindowStyle As VbAppWinStyle = vbMinimizedFocus, _ Optional ByVal Events As Boolean = True _ ) As Long 'Declarations: Const STILL_ACTIVE = &H103& Const PROCESS_QUERY_INFORMATION = &H400& Dim ProcId As Long Dim ProcHnd As Long 'Get process-handle: ProcId = Shell(PathName, WindowStyle) ProcHnd = OpenProcess(PROCESS_QUERY_INFORMATION, True, ProcId) 'wait for process end: Do If Events Then DoEvents GetExitCodeProcess ProcHnd, ShellX Loop While ShellX = STILL_ACTIVE 'clean up: CloseHandle ProcHnd End Function Sub testdunno() Dim x As Long x = ShellX("pdftk a.pdf cat 1-endodd output b.pdf") Beep ' done End Sub Thanks Oliver |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 9 Aug, 18:24, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote: It compiles for me... What is it saying is not defined... -- HTH... Jim Thomlinson "oliver" wrote: I'm trying to get code I found on the net to run - I need to open a DOS command window (to run PDFTK) I get a compile error: Sub or Function not defined. I've tried putting the full path to kernel32. Do I need add some 'References' - at the moment I have vba. excel 11.0, ole automation. office 11.0 Here are is the bit of code that won't run: Option Explicit Private Declare Function CloseHandle Lib "kernel32" ( _ ByVal hObject As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" ( _ ByVal hProcess As Long, lpExitCode As Long) As Long Private Declare Function OpenProcess Lib "kernel32" ( _ ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Public Function ShellX( _ ByVal PathName As String, _ Optional ByVal WindowStyle As VbAppWinStyle = vbMinimizedFocus, _ Optional ByVal Events As Boolean = True _ ) As Long 'Declarations: Const STILL_ACTIVE = &H103& Const PROCESS_QUERY_INFORMATION = &H400& Dim ProcId As Long Dim ProcHnd As Long 'Get process-handle: ProcId = Shell(PathName, WindowStyle) ProcHnd = OpenProcess(PROCESS_QUERY_INFORMATION, True, ProcId) 'wait for process end: Do If Events Then DoEvents GetExitCodeProcess ProcHnd, ShellX Loop While ShellX = STILL_ACTIVE 'clean up: CloseHandle ProcHnd End Function Sub testdunno() Dim x As Long x = ShellX("pdftk a.pdf cat 1-endodd output b.pdf") Beep ' done End Sub Thanks Oliver If I know that I'd be half way home. What references do you have selected? I am guessing it's something to do the kernel32 but I repleced that with full path C:\windows\system32 and it still didn't work :( |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using dcount function within user-defined worksheet function | Excel Programming | |||
Excel - User Defined Function Error: This function takes no argume | Excel Programming | |||
Need to open the Function Arguments window from VBA for a user defined function. | Excel Programming | |||
User Defined Function does not appear on Function listing | Excel Programming | |||
User-Defined Function pre-empting Built-in Function? How to undo???? | Excel Programming |