Questions about objects in vba Excel

Asked

Viewed 170 times

1

I am working now with vba, however it is a language that I had little contact in graduation, I would like to ask a question.

When a macro in an excel file calls another excel file that also has macro that was closed does not occur any error, but you try to run a macro with another open occurs an error, example:

excel file "A" runs and calls "B", ends the execution as predicted until the end of the process, but when running the same "A" leaving the "B" or any other macro open (even if not running) an error occurs.

Another question I have is with the DisplayAlerts, it by default is true and when false does not display the messages, responding in a standard way those that need to answer, but as I call this method inside excel vba?

I’ve tried to use Application.DisplayAlerts = False, I’ve tried to take the object I’m working on and put "obj".DisplayAlerts = False, however the alerts keep running, how to solve this?

  • As is the code that calls the B file, usually you need to reference what you are calling if no errors can occur. What kind of alerts occur? See this code Application.EnableEvents = False and Application.ScreenUpdating = False

  • It is calling by placing the file inside an object that receives a reference type. When I try to call this object, for example: Dim objExcel Set objExcel = CreateObject("Excel.Application" objExcel.Application.Visible = False objExcel.Application.Run "Planilha.xlsm"

  • The Displayalerts only deletes warnings and messages from Excel Application. If the warning is a VBA program error, this is not deleted by Displayalerts. And please insert the code with the example of the error of executing codes in different workbooks.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.