Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default trying to email workbook from VB6, getting error 1004

I'm using this code from VB6 to open a workbook then email it. The
workbook opens and I can read from it, write to it, format cells, etc,
but when I try to send mail I get an error:

'OutputFile contains a valid path to a working .xls file

Set oExcel = CreateObject("Excel.Application")
oExcel.UserControl = False 'do not let user interact with sheet
Sleep 1000
oExcel.Visible = DisplayExcel
Set oBook = oExcel.Workbooks.Open(OutputFile)
Sleep 1000
oBook.SendMail ", "Excel Email Test"

Run-time error '1004'
Method 'SendMail' of object _Workbook' failed

I would like to be able to send the workbook from any version of Excel
2000 or later, on any OS XP or later, if possible.

Any suggestions would be appreciated.
Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default trying to email workbook from VB6, getting error 1004

Mike S was thinking very hard :
I'm using this code from VB6 to open a workbook then email it. The workbook
opens and I can read from it, write to it, format cells, etc, but when I try
to send mail I get an error:

'OutputFile contains a valid path to a working .xls file

Set oExcel = CreateObject("Excel.Application")
oExcel.UserControl = False 'do not let user interact with sheet
Sleep 1000
oExcel.Visible = DisplayExcel
Set oBook = oExcel.Workbooks.Open(OutputFile)
Sleep 1000
oBook.SendMail ", "Excel Email Test"

Run-time error '1004'
Method 'SendMail' of object _Workbook' failed

I would like to be able to send the workbook from any version of Excel 2000
or later, on any OS XP or later, if possible.

Any suggestions would be appreciated.
Mike


Hi Mike,
Is there any reason why you can't execute Excel's FileSend ToMail
Recipient (as attachment) menuitem while the workbook is active?

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #3   Report Post  
Posted to microsoft.public.excel.programming
Junior Member
 
Posts: 11
Default trying to email workbook from VB6, getting error 1004

GS wrote:
Mike S was thinking very hard :
I'm using this code from VB6 to open a workbook then email it. The
workbook opens and I can read from it, write to it, format cells, etc,
but when I try to send mail I get an error:

'OutputFile contains a valid path to a working .xls file

Set oExcel = CreateObject("Excel.Application")
oExcel.UserControl = False 'do not let user interact with sheet
Sleep 1000
oExcel.Visible = DisplayExcel
Set oBook = oExcel.Workbooks.Open(OutputFile)
Sleep 1000
oBook.SendMail ", "Excel Email Test"

Run-time error '1004'
Method 'SendMail' of object _Workbook' failed

I would like to be able to send the workbook from any version of Excel
2000 or later, on any OS XP or later, if possible.

Any suggestions would be appreciated.
Mike


Hi Mike,
Is there any reason why you can't execute Excel's FileSend ToMail
Recipient (as attachment) menuitem while the workbook is active?


I'm automating Excel from Visual Basic 6. I decided to use a different
approach: simulating right clicking on the file in the Windows file
explorer then selecting Send To Mail Recipient, that works great. I
think the problem above was caused because I don't have Outlook
configured, but the problem is solved. Thanks for replying.
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
run macro in another workbook - error 1004 John Keith Excel Programming 7 February 24th 10 01:40 AM
Error 1004 opening workbook 1004 WembleyBear Excel Programming 2 November 30th 09 01:33 PM
Opening a workbook, passwords and error 1004. droopy928gt[_10_] Excel Programming 2 April 27th 06 01:23 PM
workbook.open throws 1004 error [email protected] Excel Programming 3 April 3rd 06 11:37 PM
shared workbook runtime error 1004 Nigel[_10_] Excel Programming 10 August 2nd 05 07:09 PM


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

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

About Us

"It's about Microsoft Excel"