Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Security Warning    Comments List
Upload Images | @Reply | Bookmark | Link | Email | Next Unseen |
Shell Start Vs FollowHyperlink
Robert Allen 
     
6 hours ago
Below is an excerpt from my VBA code.  I have several similar statements to open different types of files: .dwg, .pdf, .tif etc.
Is there any downside to using the shell command vs the FollowHyperlink (ever)?
I am assuming I can permanently ditch the FollowHyperlink.

If FileExistsWithWildcard(DwgPathFilePattern) Then
       ActualNewDwgFile = Dir(DwgPathFilePattern)
       MsgBox ("The actual drawing filename is " & ActualNewDwgFile)
       'Application.FollowHyperlink FileLocation & DwgFolder & ActualNewDwgFile
       Shell "cmd /c start """" """ & FileLocation & DwgFolder & ActualNewDwgFile & """", vbHide
       'Using the line above instead of FollowHyperlink will avoid TrustCenter warnings
    Else
       MsgBox ("No Dwg File Exists.")
    End If
Richard Rost  @Reply  
           
4 hours ago
For opening known local files from your own database, that Shell command is fine, and yes, you can use it instead of FollowHyperlink to avoid Access's hyperlink warning.

I wouldn't say FollowHyperlink is permanently obsolete, though. It's still handy when you actually want hyperlink behavior, especially for web URLs.

The main downside to your cmd /c start approach is that you're sending the file path through the command processor. If any part of that path or filename can come from user input or an outside source, be careful with command-special characters. Also, Shell only tells you whether Windows started the command process - it doesn't reliably tell you whether the associated application successfully opened the file.

For controlled filenames like your DWGs, PDFs, and TIFFs, I'd be perfectly comfortable using it. Just remember that bypassing the warning means you're taking responsibility for making sure you're only opening files you trust.
Robert Allen OP  @Reply  
     
3 hours ago
Thanks for the feedback.  The code will only be opening known files, so that sounds OK.  If something doesn't work, the user group is small enough that I am sure to hear about it.  So far, no problems with the one line of code that I have changed.
Kevin Yip  @Reply  
     
46 minutes ago
A third way is using Windows scripting host, which is basically the same as using the Shell function, right down to the need of using double-double quotes for path names that contain spaces:

     Dim ws As Variant
     Set ws = CreateObject("WScript.Shell")
     ws.Run """C:\My Documents\My File.txt"""    ' Local file
     ws.Run """\\Server\Share\Our File.txt"""    ' Network file
     ws.Run "https://599cd.com"                  ' Internet URL

A fourth way is using PowerShell, which also has better security features than the legacy cmd shell:

     ' Local file
     Shell "powershell.exe -Command ""Invoke-Item 'C:\My Documents\My File.txt'""", vbHide

     ' Network file
     Shell "powershell.exe -Command ""Invoke-Item '\\Server\Share\Our File.txt'""", vbHide

     ' Internet URL
     Shell "powershell.exe -Command "Start-Process 'https://599cd.com'", vbHide
Add a Reply Upload an Image
Next Unseen

 
 
What's This?

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 11/30/2026 3:46:12 PM. PLT: 0s