Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasmahajan

ActiveX component can't create object: 'Outlook.Application' error appering while run macro

Dear All

I have following macro I want to send email alerts from qlkview to user directly when I am running this

Activx Compnent cant create Object error is appering I am Using Version 11 and testing in server but same is

running in my desktop !

Any help will be appricated.

Thanks

Vikas

Following are the code of macro

sub ExcelFile

strDate = CDate(Date)
strDay = DatePart("d", strDate)
strMonth = DatePart("m", strDate)
strYear = DatePart("yyyy", strDate)
If strDay < 10 Then
strDay = "0" & strDay
End If
If strMonth < 10 Then
strMonth = "0" & strMonth
End If
GetFormattedDate = strMonth & "-" & strDay & "-" & strYear

Path = "D:\BI-DEVELOPMENT AREA-INDOCO\Vikas"
FileName = "Test_" & GetFormattedDate & ".xlsx"

set XLApp = CreateObject("Excel.Application")

XLApp.Visible = False
set XLDoc = XLApp.Workbooks.Add

Set A = ActiveDocument.GetSheetObject("CH14")
A.CopyBitmapToClipboard
XLDoc.Sheets(1).Paste()

' Set B = ActiveDocument.GetSheetObject("CH03")
' B.CopyBitmapToClipboard
' XLDoc.Sheets(2).Paste()

XLDoc.Sheets(1).Name = "Scheduled Releases"
XLDoc.Sheets(2).Name = "Off Cycle Enhancements"
XLDoc.Sheets(3).Delete
XLDoc.Sheets(1).Range("A1").Select

XLDoc.SaveAs Path & FileName
XLApp.Quit

strName = "vikasm@indoco.com"
'InputBox("Enter email address in jsmith@email.com format","vikasm@indoco.com")'

' Set myApp = CreateObject ("Outlook.Application")

Set vOlApp = CreateObject("Outlook.Application")
Set myMessage = myApp.CreateItem(olMailItem)

myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText

myMessage.To = strName
If strName = "" Then
Exit Sub
Else
myMessage.Attachments.Add "C:\temp\" & FileName
myMessage.Subject = "Test Email: " & Date()

myMessage.Send

msgBox("The test file for " & Date() & " was sent to " & strName & ".")

Set myMessage = Nothing
Set myApp = Nothing
Set myInspector = Nothing
Set myDoc = Nothing

end if
end sub





'
'
'
'
'sub ExcelFile
'
' strDate = CDate(Date)
' strDay = DatePart("d", strDate)
' strMonth = DatePart("m", strDate)
' strYear = DatePart("yyyy", strDate)
' If strDay < 10 Then
' strDay = "0" & strDay
' End If
' If strMonth < 10 Then
' strMonth = "0" & strMonth
' End If
' GetFormattedDate = strMonth & "-" & strDay & "-" & strYear
'
' Path = "C:\temp\"
' FileName = "Test_" & GetFormattedDate & ".xlsx"
'
' set XLApp = CreateObject("Excel.Application")
'
' XLApp.Visible = False
' set XLDoc = XLApp.Workbooks.Add
'
' Set v = ActiveDocument.Variables("vCount")
'
' Selection=v.GetContent.String
'
' ActiveDocument.GetSheetObject("CH14").CopyTableToClipboard true
' XLDoc.Sheets(1).Paste()
'
' XLDoc.Sheets(1).Columns("A:K").EntireColumn.AutoFit
'
' XLDoc.Sheets(1).Name = "Export"
'
' Set XLSheet = XLDoc.Sheets("Export")
' ActiveDocument.GetSheetObject("TX46").CopyTextToClipboard
' XLSheet.Range("A" & Selection).Select
' XLSheet.Paste
' XLSheet.Range("A1").Select
'
' XLDoc.Sheets(2).Delete
' XLDoc.Sheets(2).Delete
' XLDoc.SaveAs Path & FileName
' XLApp.Quit
'
' Set myApp = CreateObject ("Outlook.Application")
' Set myMessage = myApp.CreateItem(olMailItem)
' myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText
'
' myMessage.To = "vikasm@indoco.com"
'' InputBox("Enter email address in johnsmith@mail.com format","Email Address")
' myMessage.Attachments.Add "C:\temp\" & FileName
' myMessage.Subject = "Test File " & Date()
'
' myMessage.Send
' Msgbox("Email Sent Successfully")
'
'Set myMessage = Nothing
'Set myApp = Nothing
'Set myInspector = Nothing
'Set myDoc = Nothing
'
'end sub

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
1 Solution

Accepted Solutions
Not applicable

Vikas, Just refer Jagan Mohan link, thats what I wanted you to try. Hope that helps you.

View solution in original post

11 Replies
Not applicable

Try chaning the

Set vOlApp = CreateObject("Outlook.Application")


to

Set vOlApp = New Outlook.Application

vikasmahajan
Author

Dear Sir

Thanks for your reply

Try the same it is giving error   Class not defined: 'Outlook'    in my server.

Regards

Vikas 

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
vikasmahajan
Author

Dear Sir

Thanks for your reply

Try the same it is giving error   Class not defined: 'Outlook'    in my server.

Regards

Vikas 

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Not applicable

What i guess, it's becuase you are missing outlook dll. it is working because you have Outlook installed on your local machine.

vikasmahajan
Author

Dear Sir,

Exactly I don't have outlook in my server but still I want to send alert mails from Qlikview !

Is there any Workaround ?

Please help me.

Thanks.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Not applicable

Is there any perticular reason to use Outlook.Application to send email? If you want to just send an email, you can use

Set myMailObject = CreateObject("CDO.Message");

this will give you properties like To, From etc. you can use these properties and send email. try it.


vikasmahajan
Author

Dear Sir

I am attaching my qvw  can you modify and send me ?

Thanks

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this code by Ashok Chand in below URL, it is working for me

http://community.qlik.com/thread/40244

Regards,

Jagan.

Not applicable

Vikas, Just refer Jagan Mohan link, thats what I wanted you to try. Hope that helps you.