Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VB Code - Saving excel workbook as a web page

Hi - I am using the following code to save a workbook, attach it to an
Outlook email and send. I would like to save the workbook as a web
page and attach it. The code works and saves the file as .htm and
attaches it to an email message, but when I open the file from the
message its all coded. Can someone tell me what I'm doing wrong?

Sub EMAIL()
Set WB = ActiveWorkbook
Filename = "Projects.htm"
On Error Resume Next
Kill "H:\" & Filename
On Error GoTo 0
WB.SaveAs Filename:="H:\" & Filename
FileFormat = xlHtm

'Create and show the outlook mail item
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
'Uncomment the line below to hard code a recipient
.To = "
'Uncomment the line below to hard code a subject
.Subject = "Parts Due"
.Attachments.Add WB.FullName
.Display
End With

'Delete the temporary file
WB.ChangeFileAccess Mode:=xlReadOnly
Kill WB.FullName

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default VB Code - Saving excel workbook as a web page

The code below will correct you save problem.

Sub EMAIL()
Set WB = ActiveWorkbook
FName = "Projects.htm"
On Error Resume Next
Kill "H:" & FName
On Error GoTo 0
ActiveWorkbook.SaveAs _
Filename:="C:\temp\" & FName, _
FileFormat:=xlHtml


" wrote:

Hi - I am using the following code to save a workbook, attach it to an
Outlook email and send. I would like to save the workbook as a web
page and attach it. The code works and saves the file as .htm and
attaches it to an email message, but when I open the file from the
message its all coded. Can someone tell me what I'm doing wrong?

Sub EMAIL()
Set WB = ActiveWorkbook
Filename = "Projects.htm"
On Error Resume Next
Kill "H:\" & Filename
On Error GoTo 0
WB.SaveAs Filename:="H:\" & Filename
FileFormat = xlHtm

'Create and show the outlook mail item
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
'Uncomment the line below to hard code a recipient
.To = "
'Uncomment the line below to hard code a subject
.Subject = "Parts Due"
.Attachments.Add WB.FullName
.Display
End With

'Delete the temporary file
WB.ChangeFileAccess Mode:=xlReadOnly
Kill WB.FullName

End Sub

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
vb code for saving a workbook when shutting an excel file down Kelly 1st Excel Programming 2 June 1st 07 11:31 AM
saving worksheet without code page MVM Excel Programming 1 October 21st 05 09:01 PM
Saving as web page for workbook with frozen panes tawne Excel Discussion (Misc queries) 0 January 19th 05 07:47 PM
Saving workbook with frozen panes as web page htm Tawne Excel Programming 0 January 19th 05 06:09 PM
Saving a Workbook without code KimberlyC Excel Programming 1 August 21st 03 07:07 PM


All times are GMT +1. The time now is 02:09 AM.

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"