By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,705 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,705 IT Pros & Developers. It's quick & easy.

Problem Opening Excel Spreadsheet When Using Access command Button (VB

P: 2
Hi

Access 2002

I have a Command Buton using some VB code to open an Excel spreadsheet.

However, when the spreadsheet opens it doesn't refresh the data. The spreadsheet is a pivot table which obtains data from the Access database and I have set the refresh on open option in the pivot table options.

Am i missing something in the code ?

Any help would be appreciated.


Private Sub Command12_Click()
On Error GoTo Err_Command12_Click

Dim oApp As Object

Set oApp = CreateObject("Excel.Application")
oApp.Visible = True

'Only XL 97 supports UserControl Property
On Error Resume Next
oApp.UserControl = True

oApp.Workbooks.Open ("C:\Data\Productivity.xls")


Exit_Command12_Click:
Exit Sub

Err_Command12_Click:
MsgBox Err.Description
Resume Exit_Command12_Click

End Sub
Sep 7 '07 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,389
If you open it manually does it refresh? If so, use FollowHyperlink instead of that block of code. Actually, use FollowHyperlink anyways, easier.
Sep 7 '07 #2

P: 2
gra
It does refresh when you open manually. The hyperlink sugesstion works fine.

Thanks, that answers my question
Sep 10 '07 #3

Rabbit
Expert Mod 10K+
P: 12,389
Not a problem, good luck.
Sep 10 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.