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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate an excell cell

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
Is there any way from the push of a button to populate an excel cell with data from a field on a form?

Thanks for any suggestions

Paul
 
You can use automation to open an Excel file and then set the value of a cell. I use code something like this:
Code:
    Dim strFile as String
    Dim oXLS As Excel.Application
    Dim oWkb As Object
    strFile = "C:\TEMP\Mytemplate.xls"
    Set oXLS = CreateObject("Excel.Application")
    oXLS.Workbooks.Open strFile
    Set oWkb = oXLS.Workbooks(1)
    oWkb.Worksheets(1).Range("NamedRange") = Me.txtMyValue
    oXLS.Visible = True
    Set oXLS = Nothing
    Set oWkb = Nothing

Duane
Hook'D on Access
MS Access MVP
 
Thanks Dhookum, when i run that i get "Compile error: User-defined type not defined" I am running access 2007, is there something i need to do?

Thanks

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top