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
Have you tested the code in the Module editor? Click 'check' (top left), highlight the macro subroutine name in the box below the 'check' button, then click 'Test'. A MsgBox should work with any Module and Local Security levels.
If this doesn't work, have you ever had any macros working?
flipside
I have checked in Module editor, its showing me ****Ready****.........
No, first time working with Macro....
Done all the things, which shared by community peoples but not getting any success..
Can you see any subroutines listed in the box to the left of the editor? If not try clicking the 'Check' button above it. THEN, click a subroutine in the list box and click 'Test'.
We need to know if the error is with your VBScript setup or the way you are calling the macro.
Yes,
all the subroutines are coming in the box of the editor....
And when you test a simple one with a MsgBox, the message box appears? (Remember it may appear but be hidden behind other open programs on screen).
Today only, I checked it as suggested by community people but I did not get any message box.
Just now I again checked but no luck
Okay, try if vbscript is working OUTSIDE of Qlikview.
Go to your desktop and create a new text file but name it test.vbs (make sure there is no .txt extension). Edit the file in Notepad and put one line ...
MsgBox "Hello"
.. then save it.
Double click the file to run it and tell me if a "Hello" messagebox appears.
Looks problem with button.. put the screenshot of your button action here
If the code doesn't work when tested in the Edit Module screen as has been confirmed, then it's unlikely the button configuration will make any difference.
I think we need to ensure that VBScript CAN be run on the machine.
The problem is on parameters.
I think run macro don't accept parameters.....