Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Nou pe simpatie: ingera_31
 | Femeie 25 ani Constanta cauta Barbat 30 - 59 ani |
|
|
Mrrrr's Forum (VIEW ONLY)ReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
|
| #1 |
TRaPModerator
Postari: 960
|
|
I've encountered several problems using a simple Workbook_Open subroutine. While it seemed to work fine yesterday in testing, today when I opened Excel I get error that Personal.XLSB is corrupted. I couldn't save it in any way I tried, fortunately I had a backup and the exported modules since the backup. I think I got all back.
Anyway, this is the code that had errors today:
Private Sub Workbook_Open() If ActiveWorkbook.Name = "AAA BBBB CCCC.xlsx" Then Worksheets("Sheet1").Range("G1") = "CLASSIC" End If End Sub |
Here's the code that works fine, apparently, at least so far (after a few tests) - added this in PERSONAL.xlsb, in ThisWorkbook:
Public WithEvents App As Application
Private Sub Workbook_Open() Set App = Application End Sub Private Sub App_WorkbookOpen(ByVal Wb As Workbook) If Wb.Name = "AAA BBBB CCCC.xlsx" Then Wb.Worksheets("Sheet1").Range("G1") = "CLASSIC" End If End Sub
|
Source: https://www.mrexcel.com/board/threads/w ... st-2779714
|
|
| |
|
| #2 |
TRaPModerator
Postari: 960
|
|
The 2nd code above still works fine today.
So it passed the test.
|
|
| |
|