Browser Excel different to MS Excel SaveCopyAs debugging

mond007

New Member
Joined
Oct 9, 2008
Messages
34
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.

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
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,215,651
Messages
6,126,027
Members
449,281
Latest member
redwine77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top