Can anybody tell me .Why i am getting Error ActiveX Component Cannot CreateObject.here is the following Code.But when i write a code Set excl = CreateObject(Excel.Application) instead of Set Set excl = New Excel.Application. i got error ActiveX Component Cannot Create ObjectCode:Private Sub btPrint_Click() Dim excl As Excel.Application Dim wBook As Excel.Workbook Dim ExlSheet As Excel.Worksheet Dim m_SCompanyName As String m_SCompanyName = "AL ARABI FACTORY FOR STEEL WORKS " ' Set excl = New Excel.Application Set excl = CreateObject(Excel.Application) Set wBook = excl.Workbooks.Add Set ExlSheet = wBook.Worksheets(1) excl.Visible = True ExlSheet.Cells(2, 1).Value = m_SCompanyName ExlSheet.Cells(3, 1).Value = "P.O. BOX 14044 DAMMAM 31424 " ExlSheet.Cells(4, 1).Value = "KINGDOM OF SAUDI ARABIA " ExlSheet.Cells(5, 1).Value = "PHONE : (+9663) 812-3070 " ExlSheet.Cells(6, 1).Value = "FAX : (+9663) 812-3339 " ExlSheet.Range("A1:A2").Font.Bold = True ExlSheet.Range("A1:A2").Font.Italic = True ExlSheet.Range("A1:A5").Font.Underline = True ' ActiveSheet.Pictures.Insert (App.path & "FirmSignation.jpg"), Range("B5:D10") ' Call PlacePicture wBook.SaveAs App.path & "PurchaseOrder.Xls" ' wBook.Close savechanges:=True Set ExlSheet = Nothing Set wBook = Nothing ' excl.Quit Set excl = Nothing End Sub
i got error ACtiveX Component Cannot create Object .Kindly let me know the Idea.if Possible Kindly Explain .These two Specific Line.
Code:'Set excl = New Excel.Application Set excl = CreateObject(Excel.Application)




Reply With Quote