Cant open file... (John Nurick are you around?)

  • Thread starter Thread starter Cecilia Reyes
  • Start date Start date
C

Cecilia Reyes

Hi every one, im sorry if im such a pain in the ass, but
seriously, i´ve read a lot by know and asked for help and
my problems seems not to have a solution... for me.

The thing is i am using (or trying to use) Automation to
get and manipulate an already existing file (the last
three words are bolded and italic and everything else...)
For that purpouse, i have written this very uneffective
code; uneffective because of course, i have tried so many
things that in the end, i dont really know what it does.

So here´s the code: (in Access Module)

On Error Resume Next
Set wbk = GetObject(, "Excel.Workbooks")
If Err <> 0 Then
Set wbk = CreateObject("Excel.Workbooks")
End If

With wbk
.Open "Central.xls"
.Worksheets.Add
.Worksheets("Hoja1").Range("a1").Value = "hellooo"
.Save
End With

Of course i dont want to add another worksheet on the Wbk
or just helloooo, since im just testing.

I need to open Central.xls, run its macros and close it
without the user noticing it.
I just cant think of something else to do.
Please, help!
Ciao.
Cecilia.
 
Cecilia,
Try this code:
With CreateObject("Excel.Application")
'.Visible = True 'for debugging
Set wb = .Workbooks.Open("h:\central.xls")
.Run "testmacro"'Enter your macro name here
wb.Save
wb.Close
'wb.SaveAs "AnotherName"
.DisplayAlerts = False
.Quit
End With

Alex.

Hi every one, im sorry if im such a pain in the ass, but
seriously, i´ve read a lot by know and asked for help and
my problems seems not to have a solution... for me.

The thing is i am using (or trying to use) Automation to
get and manipulate an already existing file (the last
three words are bolded and italic and everything else...)
For that purpouse, i have written this very uneffective
code; uneffective because of course, i have tried so many
things that in the end, i dont really know what it does.

So here´s the code: (in Access Module)

On Error Resume Next
Set wbk = GetObject(, "Excel.Workbooks")
If Err <> 0 Then
Set wbk = CreateObject("Excel.Workbooks")
End If

With wbk
.Open "Central.xls"
.Worksheets.Add
.Worksheets("Hoja1").Range("a1").Value = "hellooo"
.Save
End With

Of course i dont want to add another worksheet on the Wbk
or just helloooo, since im just testing.

I need to open Central.xls, run its macros and close it
without the user noticing it.
I just cant think of something else to do.
Please, help!
Ciao.
Cecilia.
 
Thank you man!!!! you are a genius!!!
God i hope some day i´ll know how to do all the stuff you
can do.
 
Back
Top