Results 1 to 3 of 3

Thread: [RESOLVED] working with Excel from VB2005..

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    200

    Resolved [RESOLVED] working with Excel from VB2005..

    Hi. I am getting errors when writing the codes below:

    Dim oXL As Excel.Application
    Dim oWB As Excel.Workbook
    Dim oSheet As Excel.Worksheet
    Dim oRng As Excel.Range

    ' Start Excel and get Application object.
    oXL = CreateObject("Excel.Application")
    oXL.Visible = True
    ' Get a new workbook.
    oWB = oXL.Workbooks.Add
    oSheet = oWB.ActiveSheet

    errors: Type Excel.Application is not defined.
    the same errors for the other 3 Dim statements.

    This is only a small part of the code which I got from microsoft MSDN site.

    I had included the MS Excel library 12.0 Object libray reference.

    I have done this in VB6 without any problem.

    What is wrong with the above Dims? I am using VB2005 and MS Excel 2007.
    Thank you.

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: working with Excel from VB2005..

    Just ran the following under VS2005 and worked fine

    Code:
          Dim oXL As Microsoft.Office.Interop.Excel.Application
          Dim oWB As Microsoft.Office.Interop.Excel.Workbook
          Dim oSheet As Microsoft.Office.Interop.Excel.Worksheet
          Dim oRng As Microsoft.Office.Interop.Excel.Range
    
          ' Start Excel and get Application object.
          oXL = CType(CreateObject("Excel.Application"), _
             Microsoft.Office.Interop.Excel.Application)
    
          oXL.Visible = True
          ' Get a new workbook.
          oWB = oXL.Workbooks.Add
          oSheet = CType(oWB.ActiveSheet, _
             Microsoft.Office.Interop.Excel.Worksheet)

  3. #3
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: working with Excel from VB2005..

    Simple working demo attached in 2005 project. Personally I use Aspose cells for Excel work.

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