Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Opening Excel From Access (2003)

    This is my first attempt at integrating Access and Excel, so please excuse my ignorance. I am trying to use code from Alison Balter's book on Mastering Access to create an instance of Excel and create a graph in Excel. However, I keep getting an error stating "Object variable or With block variable not set". the error occurs on the following line of code:
    gobjExcel.Workbooks.Add

    The entire sub is attached as a text file.


    I'm sure it is something simple that I am too dense to see. Any help is greatly appreciated.

    Ken

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Opening Excel From Access (2003)

    The variable gobjExcel should not be declared within the cmd_RunIncRateCharts_Click event procedure, but in a general module - the g prefix indicates that it should be a global variable.
    The declaration should look like

    Public gobjExcel As Excel.Application

    and should go before all Subs and Functions in the module.

  3. #3
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Opening Excel From Access (2003)

    Hans,

    It is amazing how you so quickly identify errors.

    THANKS!

Posting Permissions

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