No writing a value in a cel of Excel

mulderm

Registered User.
Local time
Today, 11:39
Joined
Jul 3, 2004
Messages
13
Hello,


In Access I have the follow VBA-code:

sub test()

Dim ex as New Excel.Application
ex.DisplayAlerts =False
ex.Workbooks.Open "c:\test.xls

ex.Range("A1").value= "Example"

ex.ActiveWorkbook.Save
ex.Quit
ex.DisplayAlerts = True
Set ex = Nothing

End Sub

If Excel is get starting and the workbook test.xls is not open
this code workt perfect.
But if test.xls is open this code do not work, the value of
cel A1 is empty.
I want to allways write the value to Cel A1 if test.xls is
open or not opened.
Can somebody helpme?

Greetings,

mulderm
 
I´m not sure about this. I normally write a macro in excel and then run it from access.

But perhaps you need to have the workbook active in order to write to it with the "range" method.

ex.activeworkbook.range(a1).value--

Fuga.
 

Users who are viewing this thread

Back
Top Bottom