Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to access excel from VBA? HELP

Status
Not open for further replies.

dmann21

Programmer
Aug 29, 2003
3
US
I need to open an Excel spreadsheet in VBA and then access particular cells to update fields in an Access database. Anyone know how to do this in VBA?
 
Sounds like you are looking for

"DDESend Function"

I have never used it, so I don't have the code. but here's what the help file says:

The DDESend function initiates a DDE conversation with application and topic, and identifies item as the data item that will receive data. For example, if application is Microsoft Excel, topic might be "Sheet1", and item might be a row-and-column identifier, such as "R1C1", or the name of a range of cells.

The data argument specifies the information you want to send. It can be a literal string, such as "Report prepared by John", or it can be an expression that includes the result of a function that creates a string, such as "Prepared on " & Date(). If item refers to more than one piece of information, such as a named range in a Microsoft Excel worksheet that contains multiple cells, the DDESend function sends data to the first entry.

In the following example, the DDESend function sends the string "Some text" to the cell at Row 1, Column 1 in a Microsoft Excel worksheet. You can enter this expression for a text box control in the ControlSource property box on the control's property sheet:

=DDESend("Excel", "Sheet1", "R1C1", "Some text")
Suppose you want to send data from a bound control on a Microsoft Access form to a cell on a Microsoft Excel spreadsheet. The ControlSource property of the bound control already contains a field name or expression. You can create another text box or combo box and set its ControlSource property to an expression including the DDESend function, where data is the name of the bound control. For example, if you have a bound text box called LastName, you can create another text box and set its ControlSource property to the following:

=DDESend("Excel", "Sheet1", "R1C1", [LastName])



RiderJon
"I might have created ctrl+alt+del,
But Bill made it famous" - Dr. Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top