After some research on the internet and on Stackoverflow, I'm stuck on some elements about the functionning of the event : Workbook_Open (which will surely seems simple to you).
I wrote the following code :
Public Sub Workbook_Open()
' Désactivation des évènements
Application.EnableEvents = False
' Put the back color of a button to red
' line 1
CB1.BackColor = &HC0&
' Modify the RowHeight of a line
' line 2
ThisWorkbook.Worksheets("Search").Rows("12:12").RowHeight = 800
' Réactive l'évènement
Application.EnableEvents = True
End Sub
Precisions:
CB1 is the name of a button implanted on an excel sheet called "Search"
I have two different problems :
Problem n°1 :
Excel doesn't seem to recongnize the CB1 variable outside of a code written on the "Search" sheet. I don't understand why. Is the variable CB1 not supposed to be available for all the code of the Workbook ?
Problem n°2
I simply do not see why Line 2 doesn't work. Even when I write it in another procedure that I call afterwards.
Anyone can give me a suggestions ?
Best regards and thanks !
Your code should look something like this:
Public Sub Workbook_Open()
' Désactivation des évènements
Application.EnableEvents = False
' Put the back color of a button to red
' line 1
'sheet specification a requirement
Sheets("Search").CB1.BackColor = &HC0&
' Modify the RowHeight of a line
' line 2
' maximum row height is 409
Sheets("Search").Rows(12).RowHeight = 409
' Réactive l'évènement
Application.EnableEvents = True
End Sub
Please see the following link for maximum row height in Excel: https://support.office.com/en-ie/article/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.