Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2007
    Posts
    48

    Unanswered: connecting to Excel from Access VBA

    I have an Access VBA procedure trying to send data to an Excel workbook.
    the following code does not work - will not get past the compile stage. Can anyone please suggest what I am doing wrong? I suspect there needs to be a specific ADO/DAO connection specified.

    Code:
    Sub Fetch_Master_Data(ByRef strExcelPath As String)
    '  Description:-
    '  This process takes the required data from the Master DB 
    '  and loads it into the Excel workbook
     
    Dim objExcel As Excel.Workbook      <<<< COMPILER ERROR HERE
    Set objExcel = GetObject(strExcelPath)

  2. #2
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Hi

    Code:
     
    Dim objExcel As Excel.Workbook      <<<< COMPILER ERROR HERE
    Set objExcel = GetObject(strExcelPath)
    [/QUOTE]

    You have to add the excel dll in to your project

    Out of the top off my head its : Tools -> Addin
    there search for the excel libery
    add this to your project

    if its allready in see if its loaden at strat up
    and chage your 1st line to :
    Dim objExcel As NEW Excel.Workbook

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Moved to Access topic.
    George
    Home | Blog

  4. #4
    Join Date
    Dec 2007
    Posts
    48

    Thanks Marvellous George

    Many thanks George, you hit the nail on the head. The original database had all the References , but this backend DB I got after splitting the original did not automatically have them.

Posting Permissions

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