Making code global in workbook

R

Rick S.

I have found this code below to be great for opening PD files, however I do
not know how to make it global through out my workbook.
That is with out pasting the code in each and every module I create
(including worksheet modules).

Any help is appreciated.

'======
'Author: Jean-Guy Marcil
'Place this before the first procedure, at the top of the module
Private 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

'This is the function that does the work
Public Sub OpenAcrobatFile(strFile As String)
ShellExecute 0, "open", strFile, vbNullString, vbNullString, 9
End Sub

'In a regular sub, use this to call the function to open the PDF file
without any warnings:

OpenAcrobatFile "C:\MyPath\FileName.pdf"
'======
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007
 
G

GTVT06

I have found this code below to be great for opening PD files, however I do
not know how to make it global through out my workbook.
That is with out pasting the code in each and every module I create
(including worksheet modules).

Any help is appreciated.

'======
'Author: Jean-Guy Marcil
'Place this before the first procedure, at the top of the module
Private 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

'This is the function that does the work
Public Sub OpenAcrobatFile(strFile As String)
  ShellExecute 0, "open", strFile, vbNullString, vbNullString, 9
End Sub

'In a regular sub, use this to call the function to open the PDF file
without any warnings:

OpenAcrobatFile "C:\MyPath\FileName.pdf"
'======
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007

instead of using public sub try using Public Function
 
R

Rick S.

Thanks for your reply, but I think that for right now, this is over my head.
Like a stealth helicoptor, circling, repeatedly, and I don't know its there.
LOL

--
Regards

VBA.Noob.Confused
XP Pro
Office 2007
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top