Possible to access workbook properties in VBA?

JasonC71

Board Regular
Joined
Feb 10, 2008
Messages
159
Hi,

I have a need to for some code to check what workbook the code is being run on....in other words...I need it to say "if the ActiveWorkbook is X then do the following, else, do this." The thing is, I can't use workbook X's Name, as it changes quite frequently....so i'm looking for another way to check and see if workbook x is the active workbook. Under workbook properties, you have things like Author, Subject, etc. Can I call these properties from within a macro to check and see if the workbook in question is my special "X" workbook? (The name of the workbook may change, but the subject line in properties will not and is unique.)

Thanks,
Jason
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You can use:
Code:
ActiveWorkbook.BuiltinDocumentProperties("Subject")
HTH
 
Upvote 0
Thanks!!

I'll give that a try tonight...I tried to capture that with the macro recorder, but got nothing....thanks for the info.

Jason
 
Upvote 0
In case it's of interest, you can also add your own custom document properties to workbooks and check for those.
 
Upvote 0
Via the Custom tab in the Properties dialog. You can then check them using the ActiveWorkbook.CustomDocumentProperties collection in code, similar to the above. Let me know if you need more detail.
 
Upvote 0

Forum statistics

Threads
1,214,909
Messages
6,122,189
Members
449,072
Latest member
DW Draft

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