Changing Workbook Caption in Excel07

AgC

New Member
Joined
Apr 22, 2011
Messages
12
Hello,

I am trying to replace the caption of an Excel workbook with a custom caption. I've used application.caption = "custom caption" but this only adds my custom caption it doesn't remove the file name. I found the following code:


Option Explicit
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowText _
Lib "user32" Alias "SetWindowTextA" _
(ByVal hwnd As Long, _
ByVal lpString As String) As Long

Sub AlterExcelCaption(strCaption As String)
SetWindowText FindWindow("XLMAIN", Application.Caption), strCaption
End Sub

Sub test()
AlterExcelCaption "Just testing"
End Sub


This code works in Excel03 but not in 07. I think the problem is with "XLMAIN". Is there someone who can help me?

Thank you in advance.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Does this help you out?

Code:
ActiveWorkbook.Application.Windows(1).Caption = "The best workbook ever!"
 
Upvote 0
tweedle,

Thanks for the effort but it doesn't help. I want the caption to be totally customized (using the "Caption" function only adds to whatever is there).

I believe I need to use a dll as I've shown in my sample code but I can't get it to work in 2007 (it works in 2003).
 
Upvote 0
Maybe :

Code:
Sub test()

    Dim wnd As Window
    
    For Each wnd In Application.Windows
        wnd.Caption = ""
    Next
    Application.Caption = "Just testing"

End Sub
 
Upvote 0
Jaafar (or anyone who can help),

Your answer worked, however, I just notice that when the application is minimized the Caption is blank. Is there a way around this?
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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