ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Making code global in workbook (https://www.excelbanter.com/excel-programming/404491-making-code-global-workbook.html)

Rick S.

Making code global in workbook
 
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


GTVT06

Making code global in workbook
 
On Jan 17, 4:17*pm, Rick S. wrote:
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

Rick S.

Making code global in workbook
 
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



"GTVT06" wrote:

On Jan 17, 4:17 pm, Rick S. wrote:
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



All times are GMT +1. The time now is 12:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com