1 Replies - 556 Views - Last Post: 09 October 2019 - 09:06 AM Rate Topic: -----

#1 Sam1961   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-October 19

Error handling in vb6

Posted 09 October 2019 - 08:50 AM

Hi to all
Earlier I had a problem for which got the suggestion. After giving thoughts and tries manage to overcome on the issue and now can open the excel 2007 workbook/sheet and make entry. Now the problem I am facing is that every time I have to close the form before making new entry otherwise I get the error message

Run Time Error '1004":
Application-defined or object-defined error
Please help how to handle this.

Private Sub Command1_Click()

    Dim xl As New Excel.Application
     Dim xlsheet As Excel.Worksheet
    Dim xlwbook As Excel.Workbook

 Set xl = CreateObject("excel.application")
    Set xlwbook = xl.Workbooks.Open("c:\users\hp\desktop\book11.xlsx")
    Set xlsheet = xlwbook.Sheets(1)
        xl.Visible = True

    xlwbook.Sheets(1).Range("A1").Select

  ActiveCell.End(xlDown).Select
    lastrow = ActiveCell.Row
          Cells(lastrow + 1, 1).Value = Text1.Text

End Sub
:code:

This post has been edited by modi123_1: 09 October 2019 - 09:04 AM
Reason for edit:: the future, please use the [code] tag button in the editor.


Is This A Good Question/Topic? 0
  • +

Replies To: Error handling in vb6

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15728
  • View blog
  • Posts: 63,014
  • Joined: 12-June 08

Re: Error handling in vb6

Posted 09 October 2019 - 09:06 AM

Close your VB6 form or Excel as a whole?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1