Hi,
I have an Excel Sheet with some questions on it and I send this this worksheets with VBA code which works in MS Excel but when you put this file on a webpage the Thisworkbook.SaveCopyAs mypath & myfilename debugs. The code is below.
Basically I think the problem is that the version of Excel it uses in Internet Explorer does not have the same components as in MS Excel launched via your PC.
When I take the Thisworkbook.SaveCopyAs this works but as you can appreciate it does not send the file and the routine does not do what its supposed to.
Anyway, does anyone know of a way around this, as the problems are many because I am trying to send a copy of the current workbook.
I have also tried using Workbooks.add but this also causes the same problem.
Many Thanks in Advance. Kuldip
p.s. using 2003
I have an Excel Sheet with some questions on it and I send this this worksheets with VBA code which works in MS Excel but when you put this file on a webpage the Thisworkbook.SaveCopyAs mypath & myfilename debugs. The code is below.
Code:
Sub SendMail()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString, Managername
Dim OutlookErr, OutlookBox
Dim myOlApp As Object
Dim olMailItem
Dim myMail As Object
myPath = Application.DefaultFilePath & "\"
Set ThisBook = ThisWorkbook
myFilename = Left(ThisBook.Name, Len(ThisBook.Name) - 4) & "_" & Day(Date) & "_" & MonthName(Month(Date), True) & "_" & Year(Date) & "_" & Hour(Time()) & "_" & Minute(Time()) & "_" & Second(Time()) & ".xls"
ThisBook.SaveCopyAs myPath & myFilename ' ** THIS IS THE OFFENDING LINE ****
Application.DisplayAlerts = False
Set myOlApp = CreateObject("Outlook.Application") 'Create outlook
Set myMail = myOlApp.CreateItem(olMailItem) 'create mail item
With myMail
.Display
.To = ("[EMAIL="Kuldip.mond@test.com"]Kuldip.mond@test.com[/EMAIL]")
.Subject = "Online Form Submitted " & ThisWorkbook.Name
.body = "Form Submitted "
.Attachments.Add (myPath & myFilename)
End With
AppActivate (myMail)
SendKeys ("^~")
Kill (myPath & myFilename) 'delete temporary file
Application.ScreenUpdating = True
MsgBox "Your message has been sent."
Set myOlApp = Nothing 'unset variable
Set myMail = Nothing 'unset variable
End Sub
Basically I think the problem is that the version of Excel it uses in Internet Explorer does not have the same components as in MS Excel launched via your PC.
When I take the Thisworkbook.SaveCopyAs this works but as you can appreciate it does not send the file and the routine does not do what its supposed to.
Anyway, does anyone know of a way around this, as the problems are many because I am trying to send a copy of the current workbook.
I have also tried using Workbooks.add but this also causes the same problem.
Many Thanks in Advance. Kuldip
p.s. using 2003