Excel - Outlook macro

  farrow 14:19 18 Jul 2005

Anyone assist please
I am trying to write a Macro in Excel, assign it to a button which, when clicked on will send the excel spreadsheet to an e-mail address.
I can get the macro to open outlook but will not either
1. paste in an e-mail address or
2. look up an address
While the cursor is flashing in the "To" box in Outlook the macro seems to freeze at this point.

Do Excel Macros not work with other programmes or is there a anti-macro security feature in Outlook

Anyone have any ideas?


  VoG II 14:34 18 Jul 2005

In the Visual Basic Editor, Tools | References and tick Microsoft Outlook X.X Library (X.X being your version of Outlook).

  farrow 17:19 18 Jul 2005

Thanks for trying but it didn't seem to have any effect.
I wrote a macro using Macro Express and that worked perfectly. Unfortunately I can't use that as not all users of the Excel spreadsheet will have access to Macro Express. In Macro Express I had to build in time delays to allow for screen changes. Is that likely to be the problem with excel macros?

  VoG II 17:38 18 Jul 2005

You could try a delay - the following will pause for 2 seconds:

Application.Wait (Now + TimeValue("0:00:02"))

  farrow 19:08 18 Jul 2005


Thanks I will give that a go


  Access genu 21:01 18 Jul 2005

the following code will send an email through outlook, if you have the reference set

Sub SendFile()
Dim outApp As New Outlook.Application

Dim outMail As Outlook.MailItem

Set outMail = outApp.CreateItem(olMailItem)

With outMail

.To = "[email protected]"

.Subject = "Test"

.Attachments.Add ("C:\myFile.txt")


End With

End Sub

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

AMD Radeon Adrenalin release date, new features, compatible graphics cards

Print designer Kelly Anna on confident mark making & modern femininity

New iMac Pro release date, UK price & specs rumours

Comment créer, utiliser et supprimer son compte Facebook ?