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

    Auto start macro (off 97)

    Hi all i have an event procedure code in an acess form that exports a query to an excel file, i then have the code that opens the excel file that was just ouputed to for the viewer. I have a macro in that excel workbook that i would like executed everytime it is opened(ie after the export)

    the code in access is:

    Private Sub cmdExp_Click()

    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "Find All Issues by Selected Criteria2", "C:WINNTProfilesEdward SantevecchiDesktopFind All Issues By Selected Criteria2.xls"

    Dim appExcel As Excel.Application

    Set appExcel = CreateObject("Excel.Application")

    appExcel.Visible = True

    appExcel.Workbooks.Open "C:WINNTProfilesEdward SantevecchiDesktopFind All Issues By Selected Criteria2.xls"

    /////Code that runs excel macro here would be great!!!!!!!!!!////////////////////////////////

    End Sub

    If i could auto start the macro from within excel that would work or if there were code i could use in access to execute an excel macro that would do the same, i think the coding would be more difficult though. ANy suggesstions?

    Ed

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Auto start macro (off 97)

    Hi Ed,
    Something like:
    appExcel.Run "macronamehere"
    should do it.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto start macro (off 97)

    Since the workbook was already open i tried

    appExcel.Run "TopAlign"

    But it says it can not find that macro, what is the correct path to set for the macro name?

    And now i am editing this post to inform you i have finally fixed one of my own problems.

    appExcel.Run "ThisWorkbook.TopAlign"

    Hell just may freeze over tonight.....
    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
  •