Forum Statistics
- Forum Members:
- Total Threads:
- Total Posts: 17
There are 1 users currently browsing forums.
|
 |
|

02-01-2010, 06:41 AM
|
|
Registered User
|
|
Join Date: 17 Jan 2008
Posts: 98
|
|
|
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
|

02-01-2010, 07:24 AM
|
 |
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
|
|
|
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.
|

02-01-2010, 07:26 AM
|
|
Registered User
|
|
Join Date: 17 Jan 2008
Posts: 98
|
|
|
Re: import data from access table to excel pivot table - Enable Auto Refresh
more specific pls ?
|

02-01-2010, 07:30 AM
|
 |
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
|
|
|
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.
|

02-01-2010, 07:37 AM
|
|
Registered User
|
|
Join Date: 17 Jan 2008
Posts: 98
|
|
|
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 ??
|

02-01-2010, 07:46 AM
|
|
Registered User
|
|
Join Date: 17 Jan 2008
Posts: 98
|
|
|
Re: import data from access table to excel pivot table - Enable Auto Refresh
sorry. i got the code view .
|

02-01-2010, 07:54 AM
|
|
Registered User
|
|
Join Date: 17 Jan 2008
Posts: 98
|
|
|
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
|

02-01-2010, 07:58 AM
|
 |
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
|
|
|
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.
|

02-01-2010, 08:12 AM
|
|
Registered User
|
|
Join Date: 17 Jan 2008
Posts: 98
|
|
|
Re: import data from access table to excel pivot table - Enable Auto Refresh
no luck...still prompt to overwrite exit file
Last edited by okl; 02-01-2010 at 08:19 AM.
|

02-01-2010, 08:23 AM
|
 |
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
|
|
|
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.
|

02-01-2010, 08:26 AM
|
|
Registered User
|
|
Join Date: 17 Jan 2008
Posts: 98
|
|
|
Re: import data from access table to excel pivot table - Enable Auto Refresh
setwarnings didn't suppress the prompt box...
|

02-01-2010, 08:44 AM
|
 |
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
|
|
|
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.
|

02-01-2010, 09:00 AM
|
|
Registered User
|
|
Join Date: 17 Jan 2008
Posts: 98
|
|
|
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?
Last edited by okl; 02-01-2010 at 09:14 AM.
|

02-01-2010, 09:20 AM
|
 |
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
|
|
|
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.
|

02-01-2010, 09:26 AM
|
|
Registered User
|
|
Join Date: 17 Jan 2008
Posts: 98
|
|
|
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?
|
 |
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|