?
Solved

Include non-Excel steps in an Excel macro

Posted on 2014-01-07
5
Medium Priority
?
230 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 500 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 1500 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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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…

771 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