1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Access 2007 VBA Function DoCmd.RunCommand acCmdPivotExportToExcel

Discussion in 'Business Applications' started by mariaa33, Mar 14, 2012.

Thread Status:
Not open for further replies.
  1. mariaa33

    mariaa33 Thread Starter

    Aug 7, 2008
    I have a vba function that I converted from a macro but the DoCmd.RunCommand acCmdPivotExportToExcel errors out in the function with runtime error 2501 - The RunCommand action was cancelled. Is there a different way I should be doing this? I am doing a few other things first and then it opens the query but stops. I need to export the pivot table to excel and keep the format of the pivot and I am showing only the top 10.

    DoCmd.OpenQuery "CS Top 10 Query", acViewPivotTable, acEdit
    DoCmd.RunCommand acCmdPivotExportToExcel
  2. OBP

    OBP Trusted Advisor

    Mar 8, 2005
    I have never used that command, but I have seen it helps if you open Excel first
    Set xlApp = CreateObject("Excel.Application")

    xlApp.Visible = True
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1045162