Results 1 to 2 of 2

Thread: what's wrong with this code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2004
    Posts
    169

    what's wrong with this code

    when I use the following code, it seems like visual basic open a read only excel file named "book1.xls", how to avoid this? because I need to write some data into the book1.xls so I don't like it read only.

    by the way, I manually created an excel file named "book1.xls" .Is that the reason cause it to be read only when opened by my vb code? Do I need to manually created this excel file first?

    any suggestion is helpful!!!



    code:--------------------------------------------------------------------------------

    Set xl = CreateObject("Excel.Application")
    Set xlBook = xl.Workbooks.Open(App.Path & "\book1.xls")
    Set xlSheet = xlBook.Worksheets.Add

  2. #2
    Lively Member carl_mathews200's Avatar
    Join Date
    May 2004
    Location
    Wales, UK
    Posts
    94
    This needs to be in the 'Classic Visual Basic' forum but here goes anyway....

    I tried the code that you have and it works fine. How about

    Code:
    Set xl = CreateObject("Excel.Application")
    Set xlBook = xl.Workbooks.Open(App.Path & "\book1.xls", , False)
    Set xlSheet = xlBook.Worksheets.Add

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width