OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Thread Tools Search this Thread Display Modes
Old 05-04-2004, 10:45
Michael Cervantes
Posts: n/a
Default Hyperlink or run file in VBA

Anyone know how to create a hyperlink or run a file from VBA.

Thanks for your time and attention

Michael Cervantes
Reply With Quote
Old 05-04-2004, 15:17
Alex's Avatar
Alex Alex is offline
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Hyperlink or run file in VBA


You can use VBA's Shell function to launch an application:

Sub TestLaunchNotepad()
    Shell "Notepad.exe", vbNormalFocus
End Sub
But I prefer Windows API function ShellExecute which allows to open hyperlinks, send email etc.

First, you need to declare the API function at the top of your code module like this:

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 use it:

Sub TestHyperlink()
    ShellExecute 0, vbNullString, "http://www.oberonplace.com", vbNullString, vbNullString, 5
End Sub

Sub TestEmail()
    ShellExecute 0, vbNullString, "mailto:alexv@oberonplace.com", vbNullString, vbNullString, 5
End Sub
Obviously, you can use it to launch a document file (that is, open the document in an associated program). You can specify CDR, PDF, GIF, etc file name in the third parameter (instead of the URL or email address in the examples above) and the associated program will start as if you double-clicked on the document:

Sub TestPDF()
    ShellExecute 0, vbNullString, "C:\MyDocuments\My.pdf", vbNullString, vbNullString, 5
End Sub
I hope this helps
Reply With Quote
Old 06-04-2004, 12:48
Michael Cervantes
Posts: n/a
Default Thanks Alex.

Yes, I'm sure it helps.

Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
delete vba project from cdr file hotairballoon CorelDRAW/Corel DESIGNER VBA 1 18-05-2005 09:08
File Convertor to do transpararent TIFFs dan CorelDRAW/Corel DESIGNER VBA 8 22-12-2004 13:23
CD 10, VBA not returning true outline width Webster CorelDRAW/Corel DESIGNER VBA 1 24-11-2004 17:09
Open - Resize - Savefile in Photo Paint greenee Corel Photo-Paint VBA 2 28-06-2003 03:54
Detect if VBA is installed (an answer and a question) reanan CorelDRAW/Corel DESIGNER VBA 3 04-12-2002 14:35

All times are GMT -5. The time now is 13:43.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com