View Single Post
  #3  
Old June 5th 07, 03:41 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 810
Default Link to Excel File on Outlook Form, like hyperlink click and it op

The code to open a file needs the following Win32 API declaration in the
General Declarations section of a new Module (you can't put it in the code
behind the UserForm):

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

Then you can launch the file like this:

Dim varRet As Variant
varRet = Shell("""C:\Program Files\Microsoft Office\Office12\EXCEL.EXE""
""C:\Temp\myworkbook.xls""", vbNormalFocus)

Change 12 in the file path to 11 if you are using Office 2003.

The trickiest part is making the user think he's clicking on a hyperlink.
None of the built-in controls are satisfactory for replicating a true "URL
clicking experience". For example, you'd have to manually make the text blue
and underlined and write additional code to change the cursor to a
hand-with-finger during a MouseOver event for the control.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

I need to have a link on an Outlook VBA form that links and opens an
excel file, does anyone know of a way to do this? Have seen links to
internet explorer but not opening a file on a shared network drive.
Thanks John


Ads
 

Buy Anything On eBay - Remortgages - Cell Phones - Remortgages - Dedikeret server