Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 05-25-2013, 08:58 PM   #1
deanvilar
Newly Registered User
 
deanvilar's Avatar
 
Join Date: Mar 2013
Location: Philippines
Posts: 63
Thanks: 15
Thanked 0 Times in 0 Posts
deanvilar is on a distinguished road
opens an excel file and copies values from access textboxes to excel cells

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!

deanvilar is offline   Reply With Quote
Old 05-25-2013, 11:43 PM   #2
AlexHedley
Newly Registered User
 
Join Date: Aug 2012
Location: England
Posts: 171
Thanks: 0
Thanked 28 Times in 27 Posts
AlexHedley is on a distinguished road
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?
__________________
Alex Hedley
TechHelp Team Leader

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
AlexHedley is offline   Reply With Quote
Old 05-26-2013, 01:13 AM   #3
deanvilar
Newly Registered User
 
deanvilar's Avatar
 
Join Date: Mar 2013
Location: Philippines
Posts: 63
Thanks: 15
Thanked 0 Times in 0 Posts
deanvilar is on a distinguished road
Re: opens an excel file and copies values from access textboxes to excel cells

Hi ... no the excel file exists and just needs to update some cells according to access' textboxes ... thanks.

deanvilar is offline   Reply With Quote
Old 05-27-2013, 08:27 AM   #4
AlexHedley
Newly Registered User
 
Join Date: Aug 2012
Location: England
Posts: 171
Thanks: 0
Thanked 28 Times in 27 Posts
AlexHedley is on a distinguished road
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

__________________
Alex Hedley
TechHelp Team Leader

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
AlexHedley is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pls Help !!! Assigning values to Excel cells from access database jasmeetsingh89 Modules & VBA 7 08-03-2012 07:20 PM
Open Excel file from Access form, populating certain fields in the Excel file... michaeljohannes Forms 15 01-12-2011 12:42 PM
Excel 2010 Open method opens excel but not the specific file Starchildren3317 Excel 2 12-27-2010 09:43 AM
txt file locked when excel opens it DataMiner Excel 0 10-06-2006 11:16 AM
Module that Opens a Excel File BenSteckler Modules & VBA 3 03-01-2001 04:11 PM




All times are GMT -8. The time now is 10:11 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World