ZaCkOX
07-15-2010, 03:05 PM
I tried to follow the tutorial: http://www.xtremevbtalk.com/showthread.php?t=135815
But I am still a little lost... few questions. First I am using late binding because I am not sure if the client will have Excel installed on their computer. My objective is creating an excel file, and printing the file as landscape. It is optional to open the excel file.
Where I am getting the error:
Set objExcel = CreateObject("Excel.Application") 'ActiveX component can't create object
There is no references correct?
And after I create the excel file, how do I properly assign ranges and change their borders? How do I bold them or merge cells? Been trying to find help on this subject for a few hours, I am only finding help with early-binding.
What I have so far:
'Declare
'Excel
Dim objExcel As Object
Dim objWorkBook As Object
Dim objWorkSheet As Object
'Other
Dim strYear As String
Dim strExcelPath As String
'Announce
strYear = gGetSalesYear(lblTime.Caption) 'Returns 2010
strExcelPath = App.Path & "\SALES\PRINTOUT_2010.xls"
'Create New Excel File
Set objExcel = CreateObject("Excel.Application") 'Error
'Save File And Attributes
'Worksheet Setup
Set objWorkBook = objExcel.Workbooks.Add
Set objWorkSheet = objWorkBook.Worksheets("Sheet1")
'Cell Setup
'How Declare As Range?
'Cell Manipulation
'How To Change The Borders Within The Range? Or Bold? Or Merge?
'Save File
objWorkBook.SaveAs strExcelPath
'Print File
'Still searching
'Empty
'Close Sheets And Books
Set objWorkSheet = Nothing
If Not objWorkBook Is Nothing Then objWorkBook.Close
Set objWorkBook = Nothing
'Leave Application
objExcel.Quit
Set objExcel = Nothing
'Delete File, If Not Being Opened
Kill strExcelPath
But I am still a little lost... few questions. First I am using late binding because I am not sure if the client will have Excel installed on their computer. My objective is creating an excel file, and printing the file as landscape. It is optional to open the excel file.
Where I am getting the error:
Set objExcel = CreateObject("Excel.Application") 'ActiveX component can't create object
There is no references correct?
And after I create the excel file, how do I properly assign ranges and change their borders? How do I bold them or merge cells? Been trying to find help on this subject for a few hours, I am only finding help with early-binding.
What I have so far:
'Declare
'Excel
Dim objExcel As Object
Dim objWorkBook As Object
Dim objWorkSheet As Object
'Other
Dim strYear As String
Dim strExcelPath As String
'Announce
strYear = gGetSalesYear(lblTime.Caption) 'Returns 2010
strExcelPath = App.Path & "\SALES\PRINTOUT_2010.xls"
'Create New Excel File
Set objExcel = CreateObject("Excel.Application") 'Error
'Save File And Attributes
'Worksheet Setup
Set objWorkBook = objExcel.Workbooks.Add
Set objWorkSheet = objWorkBook.Worksheets("Sheet1")
'Cell Setup
'How Declare As Range?
'Cell Manipulation
'How To Change The Borders Within The Range? Or Bold? Or Merge?
'Save File
objWorkBook.SaveAs strExcelPath
'Print File
'Still searching
'Empty
'Close Sheets And Books
Set objWorkSheet = Nothing
If Not objWorkBook Is Nothing Then objWorkBook.Close
Set objWorkBook = Nothing
'Leave Application
objExcel.Quit
Set objExcel = Nothing
'Delete File, If Not Being Opened
Kill strExcelPath