ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Call Excel from VB6 disabling macros (https://www.excelbanter.com/excel-programming/319348-call-excel-vb6-disabling-macros.html)

Derek Hardison via OfficeKB.com

Call Excel from VB6 disabling macros
 
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)

--
Message posted via http://www.officekb.com

Patrick Molloy[_2_]

Call Excel from VB6 disabling macros
 
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

"Derek Hardison via OfficeKB.com" wrote:

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)

--
Message posted via http://www.officekb.com


Derek Hardison via OfficeKB.com

Call Excel from VB6 disabling macros
 
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

--
Message posted via http://www.officekb.com

Vic Eldridge[_3_]

Call Excel from VB6 disabling macros
 
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


"Derek Hardison via OfficeKB.com" wrote:

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

--
Message posted via http://www.officekb.com



All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com