Refresh Excel data when opening the Excel file

In a MS Excel 2007 file I could create a link to a SQL server database. I open the Excel file --> Data->Refresh All. This refreshes the Excel contents that is tied to the SQL server database table. Is it possible to have the Excel file refresh the data every time the Excel file is opened?

toookiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

varontronCommented:
Hi,

Yes, it's easy.  Use the Connections dialog to define the behavior.

Here are detailed instructions from MS.

http://office.microsoft.com/en-us/excel-help/refresh-connected-imported-data-HP010087045.aspx#BMautomatically_refresh_data_when_a_wor

And a screenshot
Screen-shot-2011-10-25-at-21.34..png
0
toookiAuthor Commented:
Thanks a lot. I followed the steps. It did not work for some reason -- I think my fault. I am trying again. Thanks for the link.
0
Davy2270Commented:
You can also use the auto open macro. This macro will run automatically when the workbook is opened.

Paste this code in your workbook's VBA module, and you're good to go.

Sub auto_open()
        ActiveWorkbook.RefreshAll
End Sub

Regards,
Davy
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

toookiAuthor Commented:
Thank you. Actually I cannot open the VBA module.
Mine is Excel 2007.
I do not see any "Tool" menu there.
0
Davy2270Commented:
To open the VB editor:
choose  Visual Basic in the Developer tab in the ribbon.
or
press Alt + F11

Right click on VBAproject (your workbookname) and choose Insert then Module.

Paste this code in your module - that's the big white window on the right:
Sub auto_open()
        ActiveWorkbook.RefreshAll
End Sub

Save your file. Then, when re-opening your excel file the links will be automatically updated.

If that doesn't work out for you, please share your file.

Regards,
Davy
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
toookiAuthor Commented:
It worked. Thank you,
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.