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 / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Populate Excel Workbook

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob LMS - 28 Nov 2005 20:36 GMT
What seems to be a simple task, is driving me nuts.  All I want to do is open
an existing Excel workbook and populate certain cells with values from my db.

I can't get the syntax for sheet names and cell addresses right.

Thanks in advance
APG - 28 Nov 2005 20:58 GMT
Standard format for Excel cells is Sheet1!$A$1 for Sheet1 cell A1

> What seems to be a simple task, is driving me nuts.  All I want to do is
> open
[quoted text clipped - 4 lines]
>
> Thanks in advance
Graham Mandeno - 28 Nov 2005 21:44 GMT
Hi Rob

First set a reference to the "Microsoft Excel x.x Object Library"
(Tools>References from the code window)

Then you can use code like this:

 Dim xlApp As Excel.Application
 Dim xlWkb As Excel.Workbook
 Dim xlSht As Excel.Worksheet
 Set xlApp = CreateObject("Excel.Application")
 Set xlWkb = xlApp.Workbooks.Open("C:\Test.xls")
 Set xlSht = xlWkb.Worksheets("Sheet1")
 With xlSht
   .Range("A1") = "Hello"
   .Range("A2") = "World"
   .Range("B10") = 9999
 End With
 xlWkb.Close SaveChanges:=True
 xlApp.Quit
 Set xlSht = Nothing
 Set xlWkb = Nothing
 Set xlApp = Nothing

Signature

Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

> What seems to be a simple task, is driving me nuts.  All I want to do is
> open
[quoted text clipped - 4 lines]
>
> Thanks in advance
Rob LMS - 28 Nov 2005 23:05 GMT
Thank you very much Graham.

> Hi Rob
>
[quoted text clipped - 28 lines]
> >
> > Thanks in advance
 
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.