CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2000
    Posts
    72

    why does this not work for me?

    i want to access excel from a form in vb for which i declared
    Public anyvariable As Excel.Application
    this does not seem to work.
    what can i do to access excel data from a vb form. help please.


  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: why does this not work for me?

    Have you remembered to set a reference to the 'Microsoft Excel x Object Library' ?

    I'm using Excel 2000 and this code works :


    Dim o as Excel.Application
    '
    set o = new Excel.Application
    MsgBox o.OperatingSystem
    '




    You can test this without having to set a reference :


    Dim o2 as Object
    '
    set o2 = CreateObject("Excel.Application")
    MsgBox o2.OperatingSystem
    '





    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  3. #3

    Re: why does this not work for me?

    Don't forget to set your project to use the excel library in the references.


  4. #4
    Join Date
    Jan 2000
    Posts
    72

    Re: why does this not work for me?

    i am sorry to bother you but i seem to get this error
    '
    user defined type not defined
    '
    i dont know how to set the reference to the 'Microsoft Excel x Object Library' too

    I'm using Excel 97 and vb does not seem to recognise excel at all. when i try to access
    excel from visual data manager, it says that
    driver is not recognised. what can possibly be wrong.





  5. #5
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: why does this not work for me?

    From VB, go to the 'Project', then choose 'References' (it may take a while) - then look for 'Microsoft Excel x Object Library' (where x is the version of Excel on your machine).

    The code samples posted here should then compile. You can always try the other method I posted (ie. Dim xxx As Object) without setting any references.


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  6. #6
    Join Date
    Jan 2000
    Posts
    8

    Re: why does this not work for me?

    shell "c:\prorgam files\exel\the application.exe"


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

Featured