• Auto start macro (off 97)

    Author
    Topic
    #364826

    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

    Viewing 0 reply threads
    Author
    Replies
    • #561319

      Hi Ed,
      Something like:
      appExcel.Run “macronamehere”
      should do it.
      Hope that helps.

      • #561325

        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

    Viewing 0 reply threads
    Reply To: Auto start macro (off 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: