|
-
Jun 16th, 2006, 10:26 AM
#1
Thread Starter
Junior Member
Reg : Excel
I am Happy to meet you all 
I am learning Visual Basic now.
Thru Visual Basic 6.0, Can we create an Excel file using a Template file which is in my local Drive and passing some values to that file, and finally saving it as a different name (Which is not my Template file's Name) at different location.
Here is the code, which I got from one site. ( slightly modified )
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("Excel.Application")
oBook.open = ("C:\BOM") ' (Added Line)
oBook = oExcel.Workbooks.Add
'Add data to cells of the first worksheet in the new workbook
oSheet = oBook.Worksheets(1)
oSheet.Range("A1").Value = "S.No."
oSheet.Range("B1").Value = "Description"
oSheet.Range("A1:B1").Font.Bold = True
oSheet.Range("A2").Value = "1"
oSheet.Range("B2").Value = "Nothing"
'Save the Workbook and Quit Excel
oBook.SaveAs("D:\BOMS\200378_BOM.xls")
oExcel.Quit()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|