Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Experts,
Can anybody suggest what is the syntax error in following code:
Code:
sub ExcelPath
dim Path
Path="C:\"
MsgBox "Path Assigned"
call ExportChart
end sub
Sub ExportChart
set XLAppWholeChart = CreateObject("Excel.Application")
XLAppWholeChart.Visible = False
set XLDocWholeChart = XLAppWholeChart.Workbooks.Add
ActiveDocument.GetSheetObject("CH528").CopyTableToClipboard true
XLDocWholeChart.Sheets(1).Paste()
XLDocWholeChart.Sheets(1).Name = "Export"
TableName="Flash Summary.xlsx"
File=Path&TableName
delfile(file)
XLDocWholeChart.SaveAs File
XLAppWholeChart.Quit
MsgBox "Exported"
'Object creation
call smtpsettings
end sub
sub delfile(file)
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists(file) Then
filesys.DeleteFile file
End If
MsgBox "File Deleted"
end sub
sub smtpsettings
Dim objEmail
Const cdoSendUsingPort = 2 'Send the message using SMTP
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
Const SMTPServer = "smtp"
Const SMTPPort = 5 ' Port number for SMTP
Const SMTPTimeout = 60 ' Timeout for SMTP in seconds
'Sending mail
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
'———————————————————————
' SMTP server details
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = SMTPTimeout
.Update
'———————————————————————
End With
objEmail.To = ""
objEmail.From = ""
objEmail.Subject = "Flash Summary"
objEmail.AddAttachment "C:\"
objEmail.Send
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
MsgBox ("Test Mail Sent")
End Sub
Regards,
Balraj
What error exactly u r getting?
Seems your code is fine, it showing all the message boxes.
I tried, but no luck..
Not getting any messages box...
Siva,
I am clicking on button but I am not getting any error or message or success with this code..
Don't know what is wrong or Am I missing some settings for macro?
I have crossed check the syntax and logic which is absolutely fine but not working in my case....
Hi,
Did you added the trigger to the button and called that macro?
Regards,
jagan.
Jagan,
I have added action to button to run macro which is like a trigger, if I am not wrong?
Is it required any other trigger as well?
Did you add action in the button as External-> Run Macro -> ExcelPath( macro name)?
Yes,
Done the same thing..
have you specified without any symbols right? because if you specify =,' it wont work
I have not specified any symbol.....
Better post your sample qv