Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 02-01-2010, 06:41 AM
okl okl is offline
Registered User
 
Join Date: 17 Jan 2008
Posts: 98
okl is becoming part of the community
import data from access table to excel pivot table - Enable Auto Refresh

Please Register to Remove these Ads

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
Reply With Quote
  #2  
Old 02-01-2010, 07:24 AM
romperstomper's Avatar
romperstomper romperstomper is offline
Valued Forum Contributor
 
Join Date: 04 Nov 2008
Location: The inner wardrobes of my mind
MS Office Version:95 onward (except 97)
Posts: 2,074
romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding
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.
__________________
HTH,
R.

Bad decisions make good stories.
Reply With Quote
  #3  
Old 02-01-2010, 07:26 AM
okl okl is offline
Registered User
 
Join Date: 17 Jan 2008
Posts: 98
okl is becoming part of the community
Re: import data from access table to excel pivot table - Enable Auto Refresh

more specific pls ?
Reply With Quote
  #4  
Old 02-01-2010, 07:30 AM
romperstomper's Avatar
romperstomper romperstomper is offline
Valued Forum Contributor
 
Join Date: 04 Nov 2008
Location: The inner wardrobes of my mind
MS Office Version:95 onward (except 97)
Posts: 2,074
romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding
Re: import data from access table to excel pivot table - Enable Auto Refresh

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

Bad decisions make good stories.
Reply With Quote
  #5  
Old 02-01-2010, 07:37 AM
okl okl is offline
Registered User
 
Join Date: 17 Jan 2008
Posts: 98
okl is becoming part of the community
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 ??
Reply With Quote
  #6  
Old 02-01-2010, 07:46 AM
okl okl is offline
Registered User
 
Join Date: 17 Jan 2008
Posts: 98
okl is becoming part of the community
Re: import data from access table to excel pivot table - Enable Auto Refresh

sorry. i got the code view .
Reply With Quote
  #7  
Old 02-01-2010, 07:54 AM
okl okl is offline
Registered User
 
Join Date: 17 Jan 2008
Posts: 98
okl is becoming part of the community
Re: import data from access table to excel pivot table - Enable Auto Refresh

where should i place it ?


Code:
'------------------------------------------------------------
' 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
Reply With Quote
  #8  
Old 02-01-2010, 07:58 AM
romperstomper's Avatar
romperstomper romperstomper is offline
Valued Forum Contributor
 
Join Date: 04 Nov 2008
Location: The inner wardrobes of my mind
MS Office Version:95 onward (except 97)
Posts: 2,074
romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding
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:
Code:
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
__________________
HTH,
R.

Bad decisions make good stories.
Reply With Quote
  #9  
Old 02-01-2010, 08:12 AM
okl okl is offline
Registered User
 
Join Date: 17 Jan 2008
Posts: 98
okl is becoming part of the community
Re: import data from access table to excel pivot table - Enable Auto Refresh

no luck...still prompt to overwrite exit file
Attached Images
File Type: gif Capture.gif (41.0 KB, 1 views)

Last edited by okl; 02-01-2010 at 08:19 AM.
Reply With Quote
  #10  
Old 02-01-2010, 08:23 AM
romperstomper's Avatar
romperstomper romperstomper is offline
Valued Forum Contributor
 
Join Date: 04 Nov 2008
Location: The inner wardrobes of my mind
MS Office Version:95 onward (except 97)
Posts: 2,074
romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding
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.
__________________
HTH,
R.

Bad decisions make good stories.
Reply With Quote
  #11  
Old 02-01-2010, 08:26 AM
okl okl is offline
Registered User
 
Join Date: 17 Jan 2008
Posts: 98
okl is becoming part of the community
Re: import data from access table to excel pivot table - Enable Auto Refresh

setwarnings didn't suppress the prompt box...
Reply With Quote
  #12  
Old 02-01-2010, 08:44 AM
romperstomper's Avatar
romperstomper romperstomper is offline
Valued Forum Contributor
 
Join Date: 04 Nov 2008
Location: The inner wardrobes of my mind
MS Office Version:95 onward (except 97)
Posts: 2,074
romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding
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!
__________________
HTH,
R.

Bad decisions make good stories.
Reply With Quote
  #13  
Old 02-01-2010, 09:00 AM
okl okl is offline
Registered User
 
Join Date: 17 Jan 2008
Posts: 98
okl is becoming part of the community
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
File Type: zip BT connect KT Daily Update.zip (23.6 KB, 1 views)

Last edited by okl; 02-01-2010 at 09:14 AM.
Reply With Quote
  #14  
Old 02-01-2010, 09:20 AM
romperstomper's Avatar
romperstomper romperstomper is offline
Valued Forum Contributor
 
Join Date: 04 Nov 2008
Location: The inner wardrobes of my mind
MS Office Version:95 onward (except 97)
Posts: 2,074
romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding romperstomper Has a higher level of understanding
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:
Code:
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
__________________
HTH,
R.

Bad decisions make good stories.
Reply With Quote
  #15  
Old 02-01-2010, 09:26 AM
okl okl is offline
Registered User
 
Join Date: 17 Jan 2008
Posts: 98
okl is becoming part of the community
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?
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump