Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Syntax Error in Macro Code....

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

29 Replies
sivarajs
Specialist II
Specialist II

What error exactly u r getting?

Seems your code is fine, it showing all the message boxes.

Anonymous
Not applicable
Author

I tried, but no luck..

Not getting any messages box...

Anonymous
Not applicable
Author

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....

jagan
Luminary Alumni
Luminary Alumni

Hi,

Did you added the trigger to the button and called that macro?

Regards,

jagan.

Anonymous
Not applicable
Author

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?

sivarajs
Specialist II
Specialist II

Did you add action in the button as External-> Run Macro -> ExcelPath( macro name)?

Anonymous
Not applicable
Author

Yes,

Done the same thing..

sivarajs
Specialist II
Specialist II

have you specified without any symbols right? because if you specify =,' it wont work

Anonymous
Not applicable
Author

I have not specified any symbol.....

sivarajs
Specialist II
Specialist II

Better post your sample qv