Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Send Excel attachment, but wait till Outlook closes


Re Excel 2002

I am using the following to open an Outlook new mail window with the
attached workbook:-

objExcel.Dialogs(xlDialogSendMail).Show strInvoiceEmailAddress, "Latest
invoice attached"

I first saved the file so that the attachment would get a more
meaningful name.

I then want to delete the saved file with Kill... but the code does not
wait until the Outlook window is closed.

My query is this: is it possible to give the attachmnet a different
name to the default "Book1.xls", or how do I pause the code so that I
can delete the saved file and not get a message to say the file is in
use?

Many thanks.


--
thepython
------------------------------------------------------------------------
thepython's Profile: http://www.excelforum.com/member.php...o&userid=30563
View this thread: http://www.excelforum.com/showthread...hreadid=502126

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Send Excel attachment, but wait till Outlook closes

Hi thepython

Outlook or Outlook Express







--
Regards Ron de Bruin
http://www.rondebruin.nl


"thepython" wrote in message
...

Re Excel 2002

I am using the following to open an Outlook new mail window with the
attached workbook:-

objExcel.Dialogs(xlDialogSendMail).Show strInvoiceEmailAddress, "Latest
invoice attached"

I first saved the file so that the attachment would get a more
meaningful name.

I then want to delete the saved file with Kill... but the code does not
wait until the Outlook window is closed.

My query is this: is it possible to give the attachmnet a different
name to the default "Book1.xls", or how do I pause the code so that I
can delete the saved file and not get a message to say the file is in
use?

Many thanks.


--
thepython
------------------------------------------------------------------------
thepython's Profile: http://www.excelforum.com/member.php...o&userid=30563
View this thread: http://www.excelforum.com/showthread...hreadid=502126



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Send Excel attachment, but wait till Outlook closes

Must go now

But for Outlook you can do this

Untested

Sub Mail_Outlook()
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim strbody As String
Dim Fname As String

Fname = "C:\newfilename.xls"
ThisWorkbook.SaveCopyAs Fname

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"

With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = strbody
.Attachments.Add Fname
.display 'or use .Send
End With

Kill Fname
Set OutMail = Nothing
Set OutApp = Nothing
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ron de Bruin" wrote in message ...
Hi thepython

Outlook or Outlook Express







--
Regards Ron de Bruin
http://www.rondebruin.nl


"thepython" wrote in message
...

Re Excel 2002

I am using the following to open an Outlook new mail window with the
attached workbook:-

objExcel.Dialogs(xlDialogSendMail).Show strInvoiceEmailAddress, "Latest
invoice attached"

I first saved the file so that the attachment would get a more
meaningful name.

I then want to delete the saved file with Kill... but the code does not
wait until the Outlook window is closed.

My query is this: is it possible to give the attachmnet a different
name to the default "Book1.xls", or how do I pause the code so that I
can delete the saved file and not get a message to say the file is in
use?

Many thanks.


--
thepython
------------------------------------------------------------------------
thepython's Profile: http://www.excelforum.com/member.php...o&userid=30563
View this thread: http://www.excelforum.com/showthread...hreadid=502126





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Send Excel attachment, but wait till Outlook closes


Hi Ron,

I must apologise. I am using Outlook 2002.

Again, apologies as I should have also mentioned that I am creating an
instance of Excel from within Access 2002.

I have actually cured the problem by moving the Kill statement further
to the end of the procedure (like a fool , I was trying to
'Kill' the temporary file before using objExcel.Quit).

All is well now.

Rgds, thepython


--
thepython
------------------------------------------------------------------------
thepython's Profile: http://www.excelforum.com/member.php...o&userid=30563
View this thread: http://www.excelforum.com/showthread...hreadid=502126

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 03 - Send Attachment (can't minimize Outlook window) KKate Excel Discussion (Misc queries) 0 August 10th 07 01:20 AM
Force Macro to wait till Refreshall is done NCSU_madman[_2_] Excel Programming 0 November 10th 04 05:36 PM
Send current Excel File as an attachment using Outlook 2000 ZABU Excel Programming 3 May 28th 04 04:50 AM
Send Outlook Attachment within Excel JR[_4_] Excel Programming 5 February 21st 04 09:08 PM
What 's wrong with the coding? -- about using outlook to send attachment in excel Terry Excel Programming 1 February 5th 04 10:31 PM


All times are GMT +1. The time now is 07:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"