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 / December 2003

Tip: Looking for answers? Try searching our database.

Pull specific Excel cells into field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe6Pack - 30 Dec 2003 15:48 GMT
I have a database that needs to pull data from Excel.

Specifically, my Access field should go directly to a
cell in Excel and get that value.

I'm thinking that I use some kind of VBA code to open my
Excel file and assign the cell contents to a variable
which I then use in Access.  I think I can find the cell
in Excel using a named range.

I need the exact code, though.

How do I do this?

Thx.

Joe
Ken Snell - 30 Dec 2003 16:07 GMT
This is a generic code for opening an EXCEL workbook in "read-only" mode,
reading the contents of a specific cell on a specific worksheet, saving that
value into a variable (VariableName), and then closing the workbook and
EXCEL down.

Dim xlsApp As Object, xlsWB As Object, xlsWS As Object, xlsRng As Object
Set xlsApp = CreateObject("Excel.Application")
Set xlsWB = xlsApp.Workbooks.Open("C:\FolderName\FileName.xls", , True)
Set xlsWS = xlsWB.Worksheets("WorkSheetName")
Set xlsRng = xlsWS.Range("A1")
VariableName = xlsRng.Value
Set xlsRng = Nothing
Set xlsWS = Nothing
xlsWB.Close False
Set xlsWB = Nothing
xlsApp.Quit
Set xlsApp = Nothing

Signature

      Ken Snell
<MS  ACCESS MVP>

> I have a database that needs to pull data from Excel.
>
[quoted text clipped - 13 lines]
>
> Joe
Joe6Pack - 30 Dec 2003 18:03 GMT
Ken, thanks. that helps alot.

How can I pass that variable from Excel to Access?

Joe

>-----Original Message-----
>This is a generic code for opening an EXCEL workbook in "read-only" mode,
[quoted text clipped - 34 lines]
>
>.
Ken Snell - 30 Dec 2003 19:14 GMT
The code example that I posted would be run from inside ACCESS. Thus, the
variable already in in ACCESS.

Signature

      Ken Snell
<MS  ACCESS MVP>

> Ken, thanks. that helps alot.
>
[quoted text clipped - 49 lines]
> >
> >.
Joe6Pack - 31 Dec 2003 15:30 GMT
Thank you.  It works exactly how I want it.

Joe

>-----Original Message-----
>The code example that I posted would be run from inside ACCESS. Thus, the
[quoted text clipped - 55 lines]
>
>.
 
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.