• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

launch excel macros

  • Thread starter Thread starter piratabobo
  • Start date Start date

piratabobo

Guest
hello to all
I have a problem that I hope can be solved, I have a file of excel data1.xls, within which I created a macro that I should launch from a macro created in autocad in vba, this I can do it the problem is that when I launch the macro of the excel file from autocad, excel opens wondering then saving the file after editing, I would like to insert data in excel and start the macro of excel but without
this is the code I use to launch the macro:
Code:
dim name as thong
dim xlapp as excel.application

on error resume next

'sporta i dati in excel
set xlapp = new excel.application
xlapp.visible = false
xlapp.run c:\elaboro\dati2.xls!open
xlapp.quit
set xlapp = nothing
I hope I've been quite clear and that my problem can be solved.
thanks in advance for possible help
 
Thanks for the answer, I tried and it works all ok, only that I have another problem, opened the instance of excel and did my writing operations in the excel sheet by autocad, in the end I close the instance of excel, but I realized that instead this is not closed in fact going in the management of windows, among the active processes I still find the instance of active excel, and as I use my procedure
how can I close the instances of excel after using my procedures for not intasase windows? ?
Thanks again.
 
by the eye, I didn't do a test, it seems to me that the error is in opening an instance of excel, throwing the macro open recalling the command .run and indicating the file name.
try using the .open method, in practice xlapp.open filename, launch the macro, close the workbooks(filename), close the instance.
Try and let me know.

bye
 
hi, I tried to follow your suggestion but the problem remains, this is the code I tried to use:
Code:
dim path as string
dim xlapp as excel.application

set xlapp = new excel.application

path = "c:\labor\"
dim filemacro as string
filemacro name = myfile
dim nomemacro as string
macro name = "open"

'Open
dim wbmacro as workbook
set wbmacro = xlapp.workbooks.open(path & filename)

[Bleep] I execute my writing operations in the excel file

'save & close
wbmacro.close true
xlapp.quit
set xlapp = nothing
I'm definitely wrong something but I don't understand what
 
I tried to use your code, leaving the macro "open" I can't use it to define a sub, I ran 5 times the macro in autocad with the result that excel is finished correctly, not leaving open instances.
What office version do you use?

bye
 
I use autocad 2008 and office 2007.
I noticed that when it doesn't leave open instances comes out a microsoft office error saying that office stopped working, and also this error I can't understand.

Hi.
 
Okay, I'll send you everything, if something doesn't make it clear, let me know, I'll wait for your news.
Thank you.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
ciao
Back
Top