Results 1 to 3 of 3

Thread: Please help whats wrong with this code

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Location
    london
    Posts
    31
    Dim XLSWORKBOOK As Excel.Workbook
    Dim XLSWORKSHEETS As Excel.Worksheets
    Set XLSWORKBOOK = GetObject("W:\LASTSPEND.XLS")
    Set XLSWORKSHEET = XLSWORKBOOK.Worksheets("T4OVERTIME")


    when i run this code i get error 13 type mismatch on the first set.

    please help
    thanks

    dave
    D Stonebanks

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Question

    I made an excel file with the name Lastspend.xls and a worksheet named T4OVERTIME and then pasted your code into a project. It worked fine. Do you have a reference set to the Excel library?

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Add a reference to Microsoft Excel 8.0 (or any other verssion you have: select the highest) Object Library.
    Then you can use the code like this:
    Code:
        Dim objExcel As New Excel.Application
        Dim objWorkbook As Workbook
        Dim objWorkshet As Worksheet
        
        
        Set objWorkbook = objExcel.Application.Workbooks.Open("W:\LASTSPEND.XLS")
        Set objWorkshet = objWorkbook.Worksheets("T4OVERTIME")
        objExcel.Visible = True

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