Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

opening files and programs

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Opening files and programs

Opening files and programs

ResolvedVersion 2007
Edited on Wed 14 Mar 2012, 17:11

Timothy has attended:
Access Advanced course

Opening files and programs

So,
Opening a program is easy using the shell function. Howeve I am scratching my head around how to tie this into opening a file using ShellExecute.
As I understand it, ShellExecute opens some files depending on type. I'm want to open a PDF which is not one of those types.
Can I get away with having both these functions in the same procedure or do I need to create a value in ShellExecute and send it to the Shell function when I call that?
Cheers
Tim

RE: Opening files and programs

Timothy, try the RunApp command instead. Create a macro with the Action RunApp. Then in the command line field in Action Arguments type the path to the application followed by the path to the file. E.g.

C:\Program Files\Microsoft Office\Office14\excel.exe c:\myspreadsheet.xls

Anthony

RE: Opening files and programs

Hi Anthony,
Unfortunately RunApp is not going to work in this situation. Unless I can substitute the file path with a field that contains a file path written out.
That's why I moved down the VBA route instead of trying to resolve with a macro.
Cheers
Tim

RE: Opening files and programs

Shell is a VBA keyword, ShellExecute is a Windows API function, so you don't use one to enable the other. Most people favour ShellExecute. There's a download here with a worked example which is rather good:

http://www.access-programmers.co.uk/forums/showthread.php?t=97787

Anthony

RE: Opening files and programs

Thanks Anthony,
Got it all working.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Access tip:

Calculating The Difference Between Dates

If you wish to calculate the time between two date fields, this can be done in a number of ways:

1. As a calculated field in a query
2. As a calculated control in a form or report
3. As a calculation in a VBA procedure.

The basic syntax to get the number of days between two dates is:

=[One Date Field] - [Another Date Field]

You can also use one of the following functions:

=Month([One Date Field] - [Another Date Field])
which calculates the number of months between the two fields

=Year([One Date Field] - [Another Date Field])
which calculates the number of years between the two fields.

Another function is the DateDiff() function.

It uses an argument to determine how the time interval is measured. For example:

=DateDiff("q",[One Date Field] - [Another Date Field])
returns the number of quarters between the two fields.

Other intervals that can be used in this expression are as follows:
"yyyy" - Years
"m" - Months
"d" - Days
"w" - Weekdays
"ww" - Weeks
"h" - Hours
"n" - Minutes
"s" - Seconds

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.