1 year ago

#224712

test-img

Andrei

ThisWorkbook.Activate is not working correctly at all computers

In Book1.xlsb in ThisWorkbook module I have a simple code:

Public Sub Workbook_Open()
ThisWorkbook.Activate
MsgBox ThisWorkbook.Name
End Sub

which activate Book1 workbook after opening. If another book, for example Book0 has been opened first, after opening Book1 this book (Book1) becomes active, MessageBox appear in front of Book1 and Book1 remains active after macro execution. That is, the macro works as intended on most computers.

However, on some computers the code is executed, but Book1 does not become active, the previously opened book remains active. Only if I make 'MsgBox ThisWorkbook.Name row commented — it helps, Book1 becomes active. What could be the reason and how can I get the macro to work correctly on all computers?

excel

vba

msgbox

0 Answers

Your Answer

Accepted video resources