Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2014
    Posts
    4

    Unanswered: Export Record Set to Open Excel Workbook

    Hi,

    I am trying to export a record set to a workbook that is already open.
    I have the excel references open and I have the following code so far.

    Dim XLBook As Excel.Workbook
    Dim Xl As Excel.Application
    Dim XLsheet As Excel.Worksheet


    Set Xl = CreateObject("Excel.Application")
    Set XLBook = GetObject(ExcelPath)
    Set XLsheet = XLBook.User_Input
    Sheets("User Input").Range("AX2").CopyFromRecordset Benchmarks

    But I am still getting an error.

  2. #2
    Join Date
    Nov 2010
    Posts
    84
    See an example of "Export to Excel from Access and Format Excel.zip" in the web address in the signature.

  3. #3
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Try this:
    Code:
        Dim XLBook As Excel.Workbook
        Dim Xl As Excel.Application
        Dim XLsheet As Excel.Worksheet
        
        Set Xl = CreateObject("Excel.Application")
        Set XLBook = Xl.Workbooks.Open(ExcelPath)
        Set XLsheet = XLBook.Sheets("User_Input")
        XLsheet.Range("AX2").Select
        Xl.Selection.CopyFromRecordset Benchmarks
    Have a nice day!

Posting Permissions

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