Call Excel from VB6 disabling macros

  • Thread starter Thread starter Derek Hardison via OfficeKB.com
  • Start date Start date
D

Derek Hardison via OfficeKB.com

I can call a workbook from within VB6 get infromation and close the workbook after I have what I need, but my problem is that a macro is setup to call a user form at the opening of this particular excel file, without editing the excel file, can I open it from within vb and disable the macro(s)
 
Yes. Security is at application level, so when you instantiate Excel, set
tsecurity to Medium or High. When the workbook opens, the appl will raise a
messager unless you set DisplayAllerts = False. This will allow the workbook
to open without allowing any code to run. Its designed to prevent malicious
software getting in through Office applications.

Patrick Molloy
Microsoft Excel MVP
 
First, Thank You, but I understand that and I use the excel workbook I created to keep records, therfore I like the code to run when I open it myself, but when I just want to get select info from the workbook and use it in another application created with VB6, I do not want the excel code to run. You may have answered this but I haven't had any luck with it. Maybe some sample VB6 code would help me?

Thanks again,

Derek
 
Hi Derek,

In your VB6 code, switch off Excel's events before opening the workbook.

eg.

objXL.EnableEvents = False
objXL.Workbooks.Open ...


Regards,
Vic Eldridge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top