Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
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
m_woolf
Master II
Master II

What error are you getting?

If you are getting Macro parse failed. functionality was lost, I suggest that you comment out blocks of code until the error disappears. You should be able to get down the the offending line by repeating this with smaller blocks commented each time.

Anonymous
Not applicable
Author

Micheal,

I am not getting any error in code, Macro parsing is perfectly fine.

But when I am clicking on button, I am not getting any message even exportation is also not happening...

For me it seems, I am missing some thing in the code.............

jerrysvensson
Partner - Specialist II
Partner - Specialist II

Have you set Requested Module Security to System Access and Current local Security to Allow System Access in the Macro dialogue?

Anonymous
Not applicable
Author

Yes,

I have done that......

jerrysvensson
Partner - Specialist II
Partner - Specialist II

Ok. Just to be sure. 🙂

Are you running in WebView mode?

Anonymous
Not applicable
Author

Is it mandatory???

jerrysvensson
Partner - Specialist II
Partner - Specialist II

No, the opposite. When you use WebView in Developer, Macros will not work.

Using MsgBox and Ajax as client, fails the Macro.

Anonymous
Not applicable
Author

In Developer, I am not using any webview....

Should I comment Msgbox??

I have tried without MsgBox as well but again it was not working.

After clicking on button I did not any message of failure or success!!!

jerrysvensson
Partner - Specialist II
Partner - Specialist II

Comment out all code and try this:

sub ExcelPath

MsgBox "Path Assigned"

end sub

Should give you a msgbox. If that doesn't work I have no idea what is wrong.