Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
Home   News   Tips   Glossary   Templates   Forums   Help   Logon   Order   Contact Us  

News      User Comments     History     Notify Me

11/24/2014 6:40:45 PM
Access Open Other Programs Seminar
By Richard Rost   Richard Rost on Facebook Richard Rost on Twitter Richard Rost on Google Plus Richard Rost on LinkedIn Email Richard Rost

Have you ever wanted to build a database to store an unlimited number of documents or other file attachments with each record? Perhaps you'd like to double-click on any of those files and have them automatically open up in the appropriate program? Open a Word document representing the employee's resume, or automatically have an Excel spreadsheet open up for the client's purchase order. Perhaps you'd like to click on a button next to the customer's address and have your web browser open up directly to that address into Google Maps?

This Access Open Other Programs Seminar will teach you how to open other programs, documents, and custom web page addresses from inside your Microsoft Access databases. Topics include:

1. How to display external images in Access Forms
2. Build a database to allow unlimited external attachments per customer
3. Use the SHELL function to open external files of known type
4. How to determine which application to open
5. Use SHELLEXECUTE to open file in default Windows handler app
6. Open a Web page to a custom URL in default browser
7. Load Google Maps to a Specific Address

This seminar is 1 hour and 19 minutes long. Click here for more information on the <Access Open Other Programs Seminar, including a complete course outline, sample video, and lots more.

Permanent Link
Course Link: Access Open Other Programs Seminar
Keywords: access open other files opening shell shellexec shellexecute
Page Tag: whatsnew
Post Reply

Windows Explorer Comment from Richard Lanoue @ 1/3/2019
My Problem:  Some folders I open with the Shell command I'd like to have an Extra Large Icon View and sort alphabetically.  Some folders I'd like to have when opened, List view and sorted Last Date Modified Desc.  Since these files are on an external drive, the setting I set them to, do not stay for very long.  Is there and Can you show me some code that once a specific file is open, the view and sort is set to a specific setting always?  
Sum sub folders I'd like a certain way, while the main folders are opened with cert specification of their own.

Reply from Alex Hedley:

Richard, did either of the answers to your previous questions in this thread not work?
Show Just This Thread        Post Reply
Access Open Other Programs Seminar Comment from Musab Hawsawi @ 3/21/2018
what about word automation i want to export data (dates,numbers,text ..etc) from access table in to a specific three tables (withe multi rows and columns) on ms word
Show Just This Thread        Post Reply
This ShellExec method is not working on my end for Comment from Juan Diaz @ 12/5/2017
This ShellExec method is not working on my end for pdf files.

Reply from Alex Hedley:

If you double click on a PDF what app opens?
If you check in Control Panel what is the default program to open PDFs?
Show Just This Thread        Post Reply
VB code Comment from Richard Lanoue @ 3/4/2017
I'd like to know if there is a VB code that will open a folder the way you use theses ShellExec Commands...BUT the folder ipes up to specific View Settings namely Extra Large all the time. I tried saving it but the settings eventually go to something else.  Also some folders I want the icons to be in List View and others in Extra Large view... Can you also make the window that opens up have a specific Groupby setting all the time?

Reply from Alex Hedley:

Found on another Forum. I haven't tested this.

Option Explicit

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

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
                ByVal lpClassName As String, _
                ByVal lpWindowName As String) As Long

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
                ByVal hWnd1 As Long, _
                ByVal hWnd2 As Long, _
                ByVal lpsz1 As String, _
                ByVal lpsz2 As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
                ByVal hwnd As Long, _
                ByVal wMsg As Long, _
                ByVal wParam As Long, _
                lParam As Any) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Enum FolderView
    viewDEFAULT = 0
    viewICON = &H7029
    viewLIST = &H702B
    viewREPORT = &H702C
    viewTHUMBNAIL = &H702D
    viewTILE = &H702E
End Enum

Private Const SW_SHOWNORMAL As Long = 1
Private Const WM_COMMAND = &H111

Private Sub Command1_Click()
    OpenFolder "C:\", viewREPORT
End Sub

Private Sub OpenFolder(ByVal sFolderPath As String, Optional ByVal eView As FolderView = viewDEFAULT)
    Dim N As Long, lhWnd As Long, lPrevhWnd As Long
    If Len(Dir(sFolderPath, vbDirectory)) = 0 Then Exit Sub
    lPrevhWnd = FindWindow("CabinetWClass", vbNullString)
    ShellExecute Me.hwnd, "Open", sFolderPath, vbNullString, vbNullString, SW_SHOWNORMAL
    If eView Then
            DoEvents: N = N + 1
            lhWnd = FindWindow("CabinetWClass", vbNullString)
        Loop Until Not (lPrevhWnd = lhWnd Or lhWnd = 0) Or N = 100000
        If N = 100000 Or lhWnd = 0 Then Exit Sub
        Call Sleep(100)
         lhWnd = FindWindowEx(lhWnd, 0&, "SHELLDLL_DefView", vbNullString)
        SendMessage lhWnd, WM_COMMAND, ByVal eView, 0&
    End If
End Sub

GetOpenFileName: Set an Open/Save Dialog's Initial Listview View
Show Just This Thread        Post Reply
Windows Explorer Comment from Richard Lanoue @ 1/2/2017
Is there a way where When I open a folder by clicking a button, it not only opens the folder but formats it so the Icons are always very large, sorted alphabetically and grouped by type and have one group selecting collapse so only jpg are shown?

Reply from Alex Hedley:

MS Forum

1. Open up a window in File Explorer (or hit START BUTTON followed by the letter E).

2. Open up the View Ribbon, and select the view option. In your case, you would select "large icons".

3. Still in the View Ribbon, select the "Options" icon (on the far right). If a menu drops down, select "change folder and search options".

4. From this point, things should look just like Windows XP or Windows 7. The "Folder Options" dialog should pop up. Select the "View" tab, and click the "Apply to Folders" button.
Show Just This Thread        Post Reply
Automate process Comment from Eric Michalek @ 11/16/2016
Unfortunately, I am required to use Word. These documents only contain one or two pages of text and possibly one table for text.

Reply from Alex Hedley:

Would the mail merge not work then?
Show Just This Thread        Post Reply
Automate process Comment from Eric Michalek @ 11/1/2016
My goal is to click my command button which opens a word document, do stuff (such as automatically fill out data from my database, save it with a new name to maintain the integrity of the original document, print that document, and or send it to my boss electronically).  Which of your classes does that? (I purchased many classes so far, but I need to fill in the gaps)

Reply from Alex Hedley:

There isn't much on Word Automation. Expert 19 covers basic Mail Merge.

Emailing is covered extensively in Email Seminar.
How complex is the Word Document? Could you not copy it into an MS Access Report and email that instead?
You could write a routine that saves the Report as a PDF.
Show Just This Thread        Post Reply
Double Double quote Comment from Eric Michalek @ 11/1/2016
I don't understand the Double Double quote in open program seminar lesson 2 10 minutes in.  The explanation is that because there is spaces but why should that matter?

Reply from Alex Hedley:

If you open up a command prompt (cmd) and use the command "cd" which is change directory and then pass it an argument of a file path like "c:/program files/office/" etc, if you don't quote the path the command prompt will think the space is another command so
cd "c:/program" "files/office/"
Whereas if you quote it, it will pass the whole string as a single argument
cd "c:/program files/office/"

It's like when you create a function that expects multiple arguments.

function createname(firstname, lastname)
  return first name & " " & lastname
end function

When you call this function you will get the string "Alex Hedley" returned
createname("Alex", "Hedley")
Show Just This Thread        Post Reply
I too loath the alternating colors so I simple del Comment from Dana Michaels @ 8/26/2016
I too loath the alternating colors so I simple deleted the 2nd color and got the same results as you. I never thought of using the same color...  
Show Just This Thread        Post Reply
Cant view videos Comment from Gerhard Marais @ 9/15/2015
Please note that I received the "You either do  NOT own this course, OR you have been timed out due to inactivity OR you just recently ordered this course. See below."
I have restarted the browser and open the training from within my course.
Please investigate and revert back!

Reply from Alex Hedley:

Which browser are you viewing the course in?
Did you try clearing the internet cache?

See the WalkThru or see this blog post.
Show Just This Thread        Post Reply
Embed Video Comment from Richard Lanoue @ 9/9/2015
This is probably my favorite lesson from you... I wanted to know is rather than call up a video file that uses a videoplayer... is therea script that will embed the video in a form?  similar to your site but not with a webpage but a form

Reply from Alex Hedley:

You could look for an ActiveX control that you could add to your Form but if you need to distribute the db this might not work.

One option I need to write up is generating a on the fly HTML page with the VIDEO tag that links to your video file, you could then set a web browser control to have this source, and then let the web page handle the native controls for play/pause etc
Show Just This Thread        Post Reply
Access Open Other Programs Seminar Comment from sumaila @ 4/13/2015
hi richard. am new here and i want to kow if the shell function method can be use to open a folder and upload images onto a form? if not then how

Reply from Alex Hedley:

The Shell Function can be used to open Explorer which will be your Folder, you can go to a specific folder with images in it.
But this is opening another app, if you are wanting to choose an image from a Folder/File picker you'll want to use a Common Dialog control as shown in the Imaging Seminar

Show Just This Thread        Post Reply
open to last location Comment from Richard Lanoue @ 2/4/2015
This is probably one of my favorite seminars... What I'd like to know is when we open a window for example:

Attachment = LaunchCD(Me, "C:\Movies")

It always opened to C:\Movies... Is there away where when I open the window it opens where I last left?  For Example:

I left C:\Movies\Vol1\Welcome Package
The next time I open it, opens at C:\Movies\Vol1\Welcome Package\...NOT C:\Movies... I next go to C:\Movies\Vol4\Maintence Video... and it opens from C:\Movies... I next go to C:\Movies\Vol4\Maintence Video

Reply from Alex Hedley:

I don't think it remembers
You could get the last location from the chosen file and store that in a table for use later
InStrRev to find the last slash and get that path
Show Just This Thread        Post Reply
File Picker Comment from Richard Lanoue @ 1/31/2015
THERE HAS TO BE A BETTER WAY... I would like to know the vbcode for dblclick a text field and have it open a window that when I select an object ( such as an mp4 or wmv file) the PATH placed into the text field.  Thereby eliminating the task of go to the window where the object is stored copy the path and paste it in the field...

Reply from Alex Hedley:

This is shown in the Imaging Seminar.
Show Just This Thread        Post Reply
Access Open Other Programs Seminar Comment from Nicholas S @ 1/31/2015
ok thanks, I have it now, couldn't find a link anywhere.
However, the code doesn't work on 64 bit Access 2013, I have a compile error.

"The code in this project must be updated for use on 64-bit systems.  Please review and update Declare statements and then mark them with the PtrSafe attribute"

Any advise would be most welcome please.

kind regards


Reply from Alex Hedley:

The main piece of advice is don't use 64 bit.
Rich wrote a blog article on it.
Unless you have a really good reason to there isn't much point in having it just because your system can.

There was a similar question in this thread.
You'd have to wrap the code in IF statements and server the correct function.
Show Just This Thread        Post Reply
Access Open Other Programs Seminar Comment from Nicholas S @ 1/30/2015
Where do I find the sample database with the code in it please?

Reply from Alex Hedley:

That would be the Student Databases page.
Make sure to have your course key handy to unlock it.
Show Just This Thread        Post Reply
Images and Videos in Form Comment from Richard Lanoue @ 1/29/2015
I really enjoyed this seminar and it brought a lot of ideas to my projects...
Will you do a continuation on this such as:
Use data collected and use it to display pie charts, bar and line graphs?

Also, I enjoyed how I can have a Form where a frame displays an image from file, I want to have it display video in a frame on a form that plays mp4 wmv etc... That plays when you open the form up...Will you do seminars like that?

Reply from Alex Hedley:

Did you look at the Imaging Seminar mentioned in the Course?

It doesn't cover video but you'll learn the techniques needed.
There was a wmv active x control you could add for older video files
VLC etc might add there own once installed.
Or you could build a dynamic local webpage to at the video.
Show Just This Thread        Post Reply
ShellExec Access 2013 64 Bit Comment from Josep Lluís O @ 12/14/2014
I have Windows 8.1 64 bit, so I installed Access 2013 also 64 bit. I found the solution navigating Internet and applied the some code you give, except I didnt include Private. Now it works on my computer. I have to check it at work with 32 bit systems.
Show Just This Thread        Post Reply
ShellExec Access 2013 64 Bit Comment from Josep Lluis Ortega @ 12/14/2014
What would be the code for ShellExec under Windows/Access 2013 64 bit?

Reply from Alex Hedley:

May I ask why you're using 64Bit, it's not normally necessary.
Check this Blog Post from Rich.

You can do a check, although this is VBA7 which isn't 64-Bit, 64-Bit uses VBA7 so it works.
The Keyword needed is

#If VBA7 Then
    Private Declare PtrSafe Function ShellExecute ...
    Private Declare Function ShellExecute ...
#End If

Show Just This Thread        Post Reply
Access Open Other Programs Seminar Comment from Wallis W @ 12/4/2014
The techniques demonstrated in this seminar were exactly what we needed to take our database presentations to the next level and to provide additional user access to important information. That we were shown how to do all of this without storing the files in the database was a tremendous plus. Hats off for a great resource.

Reply from Richard Rost:

Thanks, Wallis. Glad you liked it.
Show Just This Thread        Post Reply
Thanks so much Comment from Selby Halfpenny @ 11/27/2014
Dear Richard,

Thanks so much for another great great seminar, I work with Images in my databases. Always wanted to know how to open other files with different extensions. Thanks to you, now I can. Have your Imaging Seminar.

All the best to you.

Show Just This Thread        Post Reply

Add Your Comments or Subscribe
If you just want to subscribe to get email updates when the News is updated, then enter your name and email address and check the Notify Me box below. If you would optionally like to add your comments below to be posted, they are welcome.
  Your Name:  Required
  Your Email:  NOT Public


Sorry about this step. It's just to keep the spam bots away:
  Verify: What is 4+4:
  Notify me when the News is updated.
  Remember Me for my next comments
Please do not use this form for Customer Service inquiries! If you have questions about your account, shipping info, courses you've ordered, need passwords, etc. please use the Customer Service Center instead.

I value your comments. They will be displayed on this page (above). Your name will be displayed, but your email address will not be.
As always, I promise to never give away your personal information to anyone else, ever.

NOTE: If you don't leave your name and email address, DON'T expect a reply. I can't promise a personal reply to everyone who posts here. I TRY my best, but I cannot guarantee it. If you don't leave your real name and email address, I won't even bother. I usually just hit DELETE. -Richard



You may want to read these articles from the 599CD News:

8/15/2019Last Chance for Access CDs
8/1/2019Customer List Form Template
8/1/2019New Template Access Customer Database
7/30/2019Microsoft Access Developer 13
6/20/2019TIP: Validation Rules in Access
11/20/2018Microsoft Access Developer 12
8/25/2018NEW: Access Dev 9, 10, 11
8/25/2018Microsoft Access Developer 11
8/25/2018Microsoft Access Developer 10
8/25/2018Microsoft Access Developer 9

Visual Basicindex
Account Login
Online Theater
Lost Password
Free Upgrades
Insider Circle
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search Our Site
Waiting List
Production Schedule
Collapse Menus
Live Chat
Customer Support
WalkThru Tutorials
Consulting Services
About Us
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Gift CDs
Live Chat
General Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

Google Plus    LinkedIn

Blog RSS Feed    YouTube Channel
Richard Rost Microsoft MVP