opens an excel file and copies values from access textboxes to excel cells (1 Viewer)

deanvilar

Registered User.
Local time
Today, 08:13
Joined
Mar 27, 2013
Messages
63
Hello Gurus ...

Is there any simple method how to open an excel file and copy certain values from access textboxes to excel cells??

thank you!
 

AlexHedley

Registered User.
Local time
Today, 15:13
Joined
Aug 28, 2012
Messages
171
Are you wanting to create a new Excel file?
Will this be the same existing file or do you wish to choose a different file each time.
Will it always be the same cells in the Excel file?
 

deanvilar

Registered User.
Local time
Today, 08:13
Joined
Mar 27, 2013
Messages
63
Hi ... no the excel file exists and just needs to update some cells according to access' textboxes ... thanks.
 

AlexHedley

Registered User.
Local time
Today, 15:13
Joined
Aug 28, 2012
Messages
171
Initially to open the Excel file
Code:
Private Sub cmdOpenExcel_Click() 
    Dim xlApp As Excel.Application 
    Dim xlWB As Excel.Workbook 
    Set xlApp = New Excel.Application 
    With xlApp 
        .Visible = True 
        Set xlWB = .Workbooks.Open("C:\path\xlfilename.xls", , False)
    End With

'Add the textbox values to the cells in the workbook
...

    'Save and Close
    xlWB.Save
    xlWB.Close
    Set xlWB = Nothing
    Set xlApp = Nothing
End Sub
Just replace the path and file name.

Add a Reference to the Excel app:
Go to Tools | References
Add
Microsoft Excel #.0 Object Library
 

Users who are viewing this thread

Top Bottom