Getting run time error 91 in my program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • strpradeep
    New Member
    • Jul 2010
    • 1

    Getting run time error 91 in my program

    hello everyone.. i am new to vb6 and i am developing a small application using excel to create an instance of excel. the following code gives me the run time error. please help me..

    Private Sub Command3_Click( )
    Dim oXLApp As Excel.Applicati on
    Dim oXLBook As Excel.Workbook
    Dim oXLSheet As Excel.Worksheet
    Set oXLApp = New Excel.Applicati on
    Set oXLBook = oXLApp.Workbook s.Add
    Dim iSheetsPerBook As Integer
    iSheetsPerBook = oXLApp.SheetsIn NewWorkbook
    oXLApp.SheetsIn NewWorkbook = 1
    Set oXLBook = oXLApp.Workbook s.Add
    oXLApp.SheetsIn NewWorkbook = iSheetsPerBook
    Dim x As String
    Dim lMyArray(2, 0) As String
    lMyArray(0, 0) = Label1.Caption
    lMyArray(1, 0) = Label2.Caption
    lMyArray(2, 0) = Label3.Caption
    oXLSheet.Range( "A1:A3").Va lue = lMyArray
    oXLApp.Visible = True
    Set oXLSheet = Nothing
    Set oXLBook = Nothing
    Set oXLApp = Nothing
    End Sub

    Private Sub Form_Load()
    Dim oXLApp As Excel.Applicati on
    Dim oXLBook As Excel.Workbook
    Dim oXLSheet As Excel.Worksheet



    i got this code only from the internet.. as i told i am new to vb programming!!! please any help would be of great use.. thank you..
Working...