Transfering data to office Application

  • Thread starter Thread starter John Smith
  • Start date Start date
J

John Smith

Hi everyone!

I have a "Invoice Frame" made with Excel. I have build a form with some
informations and I need to transfert them in my "Invoice Frame" Excel in a
specific cell.

For Exemple, on my form I have those Field and and need them to be exported
in those cell by the push of a button... I have tried the
http://www.mvps.org/access/modules/mdl0006.htm web site but I was unable to
make it work like I want

SubTotal Field Cell F-22
Quantity Field Cell C-16
UnitPrixe Field Cell E-16

Thanks for your Help!

JS
 
Hi John,
when struggling with programming in Excel I recommend
posting your question to that newsgroup as you are likely
to get help from people with direct experience in that
application.

It's not clear whether you want to transfer data from
access to excel or the other direction. It's also not
clear whether the problem is only that you are having
trouble referencing cells in an excel workbook.

To reference the given cells you must have a reference to
the excel object library. In the visual basic editor
(moduled design view) use >>tools >>references and then
ensure that Microsoft Excel Object Library is selected in
the list.

Use the following as an example to get a value from an
excel workbook.

dim xlApp as excel.application
dim xlBook as excel.workbook
dim xlSheet as excel.worksheet
dim xlCell as excel.range

on error resume next
set xlApp=getobject(,"Excel.application")
if err.number<>0 then
' excel not open
set xlApp=new excel.application
end if

on error goto error_handler

set xlBook=xlApp.workbooks.open("path\name.xls")

set xlSheet=xlBook.worksheets(1)

set xlCell=xlSheet.range("F22")

'.... do something with xlCell.value

' closing
set xlCell=nothing
set xlSheet=nothing
set xlBook=nothing
with xlApp
if not .usercontrol then
' opened excel using code rather than had open before
..quit
end if
set xlApp=nothing


Hope the above helps
Jonathan
 
Back
Top