personal.xlsb code to set full path in title bar works on one computer but not another

Special K

Board Regular
Joined
Jun 20, 2011
Messages
83
Office Version
  1. 2010
Platform
  1. Windows
I have the following code the personal.xlsb file on my desktop computer running Excel 2010 under Windows 10:

VBA Code:
Option Explicit

' code to automatically display the full file path in the Excel title bar
' copied from here: https://www.mrexcel.com/board/threads/possible-to-always-display-full-file-path-in-title-bar-excel-2010.1206961/#post-5895948
' test comment
' might need to mark this file as 'read only' to avoid getting "open for editing" errors when opening multiple instances of Excel: https://www.systemroot.ca/2013/08/how-to-fix-file-in-use-personal-xlsb-is-locked-for-editing/

Private WithEvents xlsApp As Application

' shouldn't need to use ThisWorkbook.Application; Application should work fine
' from: https://www.mrexcel.com/board/threads/how-to-update-title-bar-to-display-full-file-path-when-document-is-saved.1211738/#post-5920546
Private Sub Workbook_Open()
    Set xlsApp = Application
End Sub

Private Sub xlsApp_WorkbookOpen(ByVal Wb As Workbook)
    ActiveWindow.Caption = Wb.FullName
End Sub

' new code to have the title bar updated whenever the document is saved; this ensures newly-created documents will have their paths displayed
' in the title bar once they are saved
' note it is not necessary to include this functionality in both the WorkbookBeforeSave and WorkbookAfterSave events; I was just copying the
' code from a reply to my thread here: https://www.mrexcel.com/board/threads/how-to-update-title-bar-to-display-full-file-path-when-document-is-saved.1211738/#post-5920546

Private Sub xlsApp_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Debug.Print Wb.FullName
    ActiveWindow.Caption = Wb.FullName
End Sub

Private Sub xlsApp_WorkbookAfterSave(ByVal Wb As Workbook, ByVal Success As Boolean)
    Debug.Print Wb.FullName
    ActiveWindow.Caption = Wb.FullName
End Sub

The code sets the title bar to display the full file path whenever a file is opened or saved. The code works fine on my desktop computer, but when I copy the file to the following location on my laptop (also running Excel 2010 under Windows 10):

VBA Code:
C:\Users\Special_K\AppData\Roaming\Microsoft\Excel\XLSTART\personal.xlsb

and then try to open an excel file, I get the following error:

Run-time error '91': Object variable or With block variable not set

In reference to the following line inside the xlsApp_WorkbookOpen(ByVal Wb As Workbook) subroutine:

ActiveWindow.Caption = Wb.FullName


How do I fix error, and why I am I only seeing it on my laptop when both computers are running the same OS and Excel versions?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top