Solved

Include non-Excel steps in an Excel macro

Posted on 2014-01-07
5
220 Views
Last Modified: 2014-01-09
Hello,

Is there any way to include non-Excel steps in an Excel macro?

For example, suppose you want to be able to click (cell G7 say) in a certain worksheet, and by doing so, have it open a blank notepad. Or suppose, by clicking cell G8, you would like to be able to open a new email window in MS Outlook.

Is that doable?

Thanks
0
Comment
Question by:Steve_Brady
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 14

Assisted Solution

by:Farzad Akbarnejad
Farzad Akbarnejad earned 125 total points
ID: 39764249
Hi,
See the attached workbook. It contains VBA code in Sheet1 code page
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target = Range("G7") Then
        Shell "Notepad"
    ElseIf Target = Range("G8") Then
        Shell "outlook.exe /c ipm.note /m someone@somewhere.foo"
    End If
End Sub

Open in new window

-FA
Book1.xlsm
0
 
LVL 81

Accepted Solution

by:
byundt earned 375 total points
ID: 39764256
You can launch other applications from an Excel macro. One way is to create an object pointing to the other application. This may be done using early-binding (requires setting a reference to a particular version of the other application) or late-binding (runs slower, but doesn't generate an error message if the user has a different version of the application than you do). I use early-binding during program development because it exposes the object model for the other application, but then switch to late-binding before delivering the project to avoid the run-time error messages.

The other way is to use Shell to launch the application (as FarzadA has done). Use this approach if creating an object pointing to the other application doesn't work (such as for MS Paint).

Details of exactly how to do it will depend on the application you need to run, and whether it might already be running.
0
 
LVL 81

Assisted Solution

by:byundt
byundt earned 375 total points
ID: 39764278
Further to the discussion on late-binding for Outlook, Microsoft Excel MVP Ron deBruin offers an enormous amount of code for automating Outlook from Excel. Here is a typical page, where he shows how to send a small email message using an Excel macro and late-binding. http://www.rondebruin.nl/win/s1/outlook/bmail4.htm
0
 

Author Closing Comment

by:Steve_Brady
ID: 39769713
Thanks for the responses. I appreciate the input and the links.
0
 

Author Comment

by:Steve_Brady
ID: 39769750
This thread has given rise to a couple of other questions having to do with Excel macros producing global output. Rather than add that on to this thread, I opted to begin a new one which I will post shortly.

Thanks again
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question