Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / August 2005

Tip: Looking for answers? Try searching our database.

How do I refresh external data in Excel via linked table in Access

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff Koons - 25 Aug 2005 15:21 GMT
I have an Excel file that pulls external data from our Oracle application via
a web query created by a third-party vendor, Noetix. I have also created an
Access database that has a link to this Excel file. I would like to have
Access refresh the external data in Excel before using that linked table. As
it is right now, the user has to open the Excel file, refresh the data, save
and close the file, open Access and proceed with processing data.
Roger Carlson - 25 Aug 2005 20:29 GMT
Not knowing the exact process you use to refresh the data, I can only give
you a rough outline.

First, I would go into Excel, start the Macro Recorder and then perform the
refresh, then stop the Macro Recorder.  Hopefully this will capture the
programmatic steps to perform this.

Next, go to Access and create a reference to Excel in your References
(Tools>References in any code window).

Lastly, create an Event Procedure for a button.  In this subroutine, create
an Excel Automation object in code, then paste the code recorded in the
macro there.  The code won't work by itself until you use the Excel object
as a prefix.

For an example, let me show code that just opens then saves the file as a
different name:

Dim objXLApp As Object
Set objXLApp = CreateObject("Excel.Application")
Dim objXLBook As Excel.Workbook

  ' open a workbook
   Set objXLApp = New Excel.Application
   Set objXLBook = objXLApp.Workbooks.Open("C:\the\path\to\your\File.xls")

'PASTE YOUR CODE HERE

   objXLBook.SaveAs ("C:\the\path\to\your\File2.xls")
   objXLBook.Close

Now, when I say add a prefix, I mean you'll want to add objXLBook before
each command.  For instance, if you record the SaveAs in the Macro Recorder,
it will look something like this:
       ActiveWorkbook.SaveAs Filename:="I:\Book1.xls",
FileFormat:=xlNormal, _
       Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
       CreateBackup:=False

To make it work as I did above, I had to replace ActiveWorkbook with the
Excel object:
      objXLBook.SaveAs Filename:="C:\the\path\to\your\File.xls",
FileFormat:=xlNormal, _
       Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
       CreateBackup:=False

(Actually, as you can see I used a shorthand version, but the one above
would have worked just as well.)

Does this help?

Signature

--Roger Carlson
 Access Database Samples: www.rogersaccesslibrary.com
 Want answers to your Access questions in your Email?
 Free subscription:
 http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L

> I have an Excel file that pulls external data from our Oracle application via
> a web query created by a third-party vendor, Noetix. I have also created an
> Access database that has a link to this Excel file. I would like to have
> Access refresh the external data in Excel before using that linked table. As
> it is right now, the user has to open the Excel file, refresh the data, save
> and close the file, open Access and proceed with processing data.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.