Solved

Include non-Excel steps in an Excel macro

Posted on 2014-01-07
5
188 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
  • 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 80

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 80

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
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…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now