Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Thanked 0 Times in 0 Posts

    Open/close xls from Access (office 97)

    hi out there,

    I have a macro that runs a query and then sends a lsit of names to a dumby excel file. Then on my main excel file i reference the list of names from the query to a column and use that as the source for my list box.

    Here are the parts i need help on:
    1) I know how to run the query and export the data to the dumby sheet

    2) How can i make the next step of this macro to be to open up a desired excel file? Where would i enter it.? I am thinking there is a commmand line in module that i can use. This will be the main file that the dumby file gets refernced to.

    3) I then need to close the dummy file as the next step of the macro. If there's a command to open a file there should be on to close a file as well??

    Does anyone out there know the syntax to open and close excel files from access?? Your help is greatly appreciated. Also, please be very detailedin your explanation because i am a VB newbie. Thank you again!!!


  2. #2
    New Lounger
    Join Date
    Jan 2001
    Thanked 0 Times in 0 Posts

    Re: Open/close xls from Access (office 97)

    Dim strFileName As String
    strMissingStoresFileName = "c:dirfilename.xls"

    ' Open the workbook
    Set xlapp = CreateObject("Excel.Application")
    xlapp.Visible = True
    Set xlbook = xlapp.Workbooks.Open(strFileName)

    ' Close the workbook
    xlbook.Close SaveChanges:=True

    ' Release objects

    Set xlbook = Nothing
    Set xlapp = Nothing

Posting Permissions

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