LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Showing a .PDF From Excel Button Using VBA

Hi Joey,

You can use the ShellExecute API function for this. Basically, when used
with the "open" verb, ShellExecute will open the specified file with its
default application. Here's the code needed to do it:

Private Const SW_SHOWMAXIMIZED = 3

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


Public Function gbOpenFile(rsPath As String) As Boolean
If ShellExecute(0, "open", rsPath & vbNullChar, _
vbNullString, vbNullString, SW_SHOWMAXIMIZED) 32 Then
gbOpenFile = True
End If
End Function


There are other SW_* constants that determine how the window is displayed.
There are lots of return value constants that can help you trap runtime
errors (instead of just checking for 32), too - just look for shellexecute
on MSDN for more info on them.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Joey wrote:
I have an Excel form that when a user clicks a button, I want to open
up a particular .PDF file on the screen. Can anyone show me the code
necessary to do this??
TIA


 
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
resize my worksheet-there is no maximize button showing dj95 Excel Discussion (Misc queries) 3 April 9th 10 07:47 AM
How to fix my spreadsheet from showing formula to showing answer SimplyQuick Excel Discussion (Misc queries) 4 October 7th 08 10:00 PM
How to fix my spreadsheet from showing formula to showing answer SimplyQuick Excel Discussion (Misc queries) 0 October 7th 08 06:38 PM
Date showing incorrect. 30:00 hrs showing 06:00 AlanStotty Excel Discussion (Misc queries) 4 August 9th 07 01:44 PM
Showing/ not showing "getting started" when excel starts Ask Excel Discussion (Misc queries) 1 July 20th 05 04:20 PM


All times are GMT +1. The time now is 08:06 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"