access to excel information passing

francoiss

Registered User.
Local time
Today, 08:54
Joined
Mar 6, 2007
Messages
14
is it possible to pass information from access to excel?

scenario:

you run an access application.
in the access form there is a button that when you click it, will launch excel
now, what if you want some onformation from access to be passed to excel,
is this possible?

thanks! :D
 
Totally possible. I do it all of the time. The simple way to do it is like this:

1. Set a reference to Microsoft Excel within Access (you don't have to do this, but using early binding you can use the intelli-sense and I like that.

2. use code like this (this is very simplified and you can find out, to some extent, what code you want by recording a macro within Excel to do what you want and then tweak it and put it into Access):

Code:
Dim objExcel As Excel.Application
Dim xlWB As Excel.Workbook

Set objExcel = New Excel.Application
objExcel.Visible = True

Set xlWB = objExcel.Workbooks.Open("C:\YourWorkBookName")

With xlWB
.Activesheet = "MySheetIWantStuffOn"
.Range("D5").Value = Me.MyAccessTextBoxValue
End With

objExcel.Save

You should also remember to fully qualify your code (use xlWB.ActiveSheet, etc. instead of just Activecell) otherwise Access will keep the Excel application instantiation open until you close Access.
 
nice :D

thanks a lot bob!
 

Users who are viewing this thread

Back
Top Bottom