Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Sub or Function not defined

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Sub or Function not defined

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Sub or Function not defined

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using dcount function within user-defined worksheet function pongthai Excel Programming 3 January 15th 07 09:55 AM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Need to open the Function Arguments window from VBA for a user defined function. [email protected] Excel Programming 0 June 20th 06 03:53 PM
User Defined Function does not appear on Function listing H.P.Hoeie, Norway Excel Programming 1 March 21st 06 10:27 AM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 10:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"