Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Aug 2001
    Location
    Toronto, Ontario, Canada
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Running Excel97 code from Access97 (97)

    Is there a way to run a function in Excel from an Access database. Right now, I export my files using Access then launch Excel and run a function which formats all the files in a uniform manner. Just wandered if anyone knew if I could do it in one step or not?

    Thanks,

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Running Excel97 code from Access97 (97)

    Yes - we do this in several cases where we create an Excel workbook based on data in Access, and do all the formating and build charts etc before we ever save the workbook. It requires the use of OLE Automation (often referred to as just Automation). There are some white papers available on the subject in the MS Knowledge Base, and some good examples in the Access Developers Handbook. Hope this encourages you.
    Wendell

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Running Excel97 code from Access97 (97)

    There's an Office Automation white paper and samples covering both Access 97 and 2000 from <A target="_blank" HREF=http://download.microsoft.com/download/office2000dev/sample/2/WIN98/EN-US/OFFAUTMN.EXE>http://download.microsoft.com/download/off...US/OFFAUTMN.EXE</A>.
    Charlotte

  4. #4
    Lounger
    Join Date
    Aug 2001
    Location
    Toronto, Ontario, Canada
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Excel97 code from Access97 (97)

    Thank you - printed off the White Paper and will sit and read the bits I need.

    I actually also got some code from another Forum which did the trick perfectly. If anyone else is interested, here it is. Runs an Excel macro from Access.

    Function RunExcelMacro()
    On Error GoTo Err_RunExcelMacro

    Dim XL As Object
    Set XL = CreateObject("Excel.Application")

    With XL.Application
    .Visible = True
    .workbooks.Open "C:Winntpersonal.xls"
    .Run "TCTICAD"
    .Quit
    End With

    Set XL = Nothing

    Exit_RunExcelMacro:
    Exit Function

    Err_RunExcelMacro:
    Debug.Print err.DESCRIPTION & " " & err.Number
    Resume Exit_RunExcelMacro

    End Function

Posting Permissions

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