How to Create More than 3 Excel Sheets in one Work Book Using VB6?

i am using a button in form to craete EI am able to create 3 excel she

Page 1 of 1

1 Replies - 6439 Views - Last Post: 16 December 2009 - 02:57 AM Rate Topic: -----

#1 isitsimple  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-December 09

How to Create More than 3 Excel Sheets in one Work Book Using VB6?

Posted 15 December 2009 - 05:57 AM

How to Create More than 3 Excel Sheets in one Work Book Using VB6?
i am using a button in form to craete Excel Shhets in workbook. I am able to create 3 excel sheets using VB6. I want to create more work sheets . PLz Tell me how to get that? Also the following code is not able to stop executing. It keeps running after creating the excel and saving it. i have to manually stop it.

Private Sub Command1_Click()
Call conn_excel
End Sub

Public Sub conn_excel()
Set xl_app = Excel.Application
Set xl_book = Excel.Application.Workbooks.Add

'First Work Sheet Creaation
Set xl_Worksheet1 = xl_book.Worksheets(1)
xl_Worksheet1.Name = "Test Data"
xl_Worksheet1.Rows("1:200").Font.Bold = True
xl_Worksheet1.Range("A1:F200").ColumnWidth = 15
'Second Work Sheet Creaation
Set xl_Worksheet2 = xl_book.Worksheets(2)
xl_Worksheet2.Name = "Coal Analysis"
xl_Worksheet2.Rows("1:200").Font.Bold = True
xl_Worksheet2.Range("A1:F200").ColumnWidth = 15
'Third Work Sheet Creaation
Set xl_Worksheet3 = xl_book.Worksheets(3)
xl_Worksheet3.Name = "Enthalpy Calculation"
xl_Worksheet3.Rows("1:200").Font.Bold = True
xl_Worksheet3.Range("A1:F200").ColumnWidth = 15


xl_app.DisplayAlerts = False
xl_app.ActiveWorkbook.SaveAs ("D:\xl_lib\some1_name.xls")

xl_app.ActiveWorkbook.Close
xl_app.Quit

End Sub

This post has been edited by isitsimple: 15 December 2009 - 05:57 AM


Is This A Good Question/Topic? 0
  • +

Replies To: How to Create More than 3 Excel Sheets in one Work Book Using VB6?

#2 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: How to Create More than 3 Excel Sheets in one Work Book Using VB6?

Posted 16 December 2009 - 02:57 AM

just do this
Set xl_Worksheet1 = xl_book.Worksheets.add
Set xl_Worksheet2 = xl_book.Worksheets.add
Set xl_Worksheet3 = xl_book.Worksheets.add


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1