+ Reply to Thread
Results 1 to 17 of 17

import data from access table to excel pivot table - Enable Auto Refresh

Hybrid View

okl import data from access table... 02-01-2010, 06:41 AM
romperstomper Re: import data from access... 02-01-2010, 07:24 AM
okl Re: import data from access... 02-01-2010, 07:26 AM
romperstomper Re: import data from access... 02-01-2010, 07:30 AM
okl Re: import data from access... 02-01-2010, 07:37 AM
okl Re: import data from access... 02-01-2010, 07:54 AM
okl Re: import data from access... 02-01-2010, 07:46 AM
romperstomper Re: import data from access... 02-01-2010, 07:58 AM
okl Re: import data from access... 02-01-2010, 08:12 AM
romperstomper Re: import data from access... 02-01-2010, 08:23 AM
okl Re: import data from access... 02-01-2010, 08:26 AM
romperstomper Re: import data from access... 02-01-2010, 08:44 AM
okl Re: import data from access... 02-01-2010, 09:00 AM
romperstomper Re: import data from access... 02-01-2010, 09:20 AM
okl Re: import data from access... 02-01-2010, 09:26 AM
romperstomper Re: import data from access... 02-01-2010, 09:36 AM
okl Re: import data from access... 02-01-2010, 09:38 AM
  1. #1
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    import data from access table to excel pivot table - Enable Auto Refresh

    Hi,

    I have enable Refresh on Open for my excel pivot table, but user need to click "Enable Automatic Refresh" , only solution i came across is to change the registry setting. Which i dont have access to edit registry(admin disable the access).

    Alternate solution i try to use Access macro to automate the process and use Outputto save it as a excel file A. Then use excel file B to update pivot table from excel file A.(as excel A data is always latest)
    The problem is i will get "....A file name already exist...do you want to overwrite.." prompt.
    Which defeat the automate process.

    Any other solution to enable the automatic refresh on open the excel workbook?

    Or Access can overwrite the exist file or save it as another file name with timestamp ?

    Thanks

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,173

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    You can use the Kill command to delete an existing file, if that helps.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    more specific pls ?

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,173

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    Something like:
    strFile = "C:\folder1\workbook_name.xls"
    If Dir(strFile) <> "" then Kill strFile

  5. #5
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    sorry, where should i insert this code into ?

    im in Macro design mode, cant find the view code to copy into ??

  6. #6
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    where should i place it ?


    '------------------------------------------------------------
    ' Macro11
    '
    '------------------------------------------------------------
    Function Macro11()
    
    strFile = "C:\Users\okl\Desktop\book.xls"
    If Dir(strFile) <> "" Then Kill strFile
    
    On Error GoTo Macro11_Err
    
        DoCmd.SetWarnings False
        DoCmd.OutputTo acTable, "sdf", "MicrosoftExcelBiff8(*.xls)", "C:\Users\okl\Desktop\book.xls", False, "", 0
    
    
    Macro11_Exit:
        Exit Function
    
    Macro11_Err:
        MsgBox Error$
        Resume Macro11_Exit
    
    End Function

  7. #7
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    sorry. i got the code view .

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,173

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    That should be fine, but you may as well use the file variable in the OutputTo method too:
    Function Macro11()
    
    strFile = "C:\Users\okl\Desktop\book.xls"
    If Dir(strFile) <> "" Then Kill strFile
    
    On Error GoTo Macro11_Err
    
        DoCmd.SetWarnings False
        DoCmd.OutputTo acTable, "sdf", "MicrosoftExcelBiff8(*.xls)", strFile, False, "", 0
    
    
    Macro11_Exit:
        Exit Function
    
    Macro11_Err:
        MsgBox Error$
        Resume Macro11_Exit
    
    End Function

  9. #9
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    no luck...still prompt to overwrite exit file
    Attached Images Attached Images
    Last edited by okl; 02-01-2010 at 08:19 AM.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,173

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    I have to assume that it's not that code that is being run when the message appears then - the DoCmd.SetWarnings code should be suppressing the prompt already.

  11. #11
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    setwarnings didn't suppress the prompt box...

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,173

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    It works for me (always has, and I just tested again using your code, but with different file path). Put a breakpoint in the code (select a line and press f9) and then run it as normal just to make sure this is actually the code that is being run!

  13. #13
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    in the Access->Tools->Macro->Convert Macros to Visual Basic

    Then i copy and paste the code in right?
    Attached Files Attached Files
    Last edited by okl; 02-01-2010 at 09:14 AM.

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,173

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    Yes - how are you actually running the code?
    You may also want to try this version:
    Function Macro11()
    
    strFile = "C:\Users\okl\Desktop\book.xls"
    If Dir(strFile) <> "" Then Kill strFile
    
    On Error GoTo Macro11_Err
    
        DoCmd.SetWarnings False
        DoCmd.OutputTo acTable, "sdf", acFormatXLS, strFile, False, "", 0
    
    
    Macro11_Exit:
        Exit Function
    
    Macro11_Err:
        MsgBox Error$
        Resume Macro11_Exit
    
    End Function

  15. #15
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    i just go macro design view and press on the run button?

  16. #16
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,173

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    No. You currently have two versions of your macro - the original Macro1 in your Macros list (which I suspect is what you are running) and the version that has been converted to VBA. How do you want/intend to run this in future?
    I am attaching a version of your file in which I have altered your Macro1 macro so that it runs the VBA version of the original macro instead. Let me know if that works for you?
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    Re: import data from access table to excel pivot table - Enable Auto Refresh

    ah...okie, thanks!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1