Retrieve Name of a Document That's Being Opened ?

KenWit

Board Regular
Joined
Nov 21, 2011
Messages
68
A message box I made pops up when I open a word document that reminds me of things to do with my current project(s). "Italicize dialogue," etc. I put the code in Normal's ThisDocument/Open. Somehow I'd like this macro/message box to be skipped when "notepad.doc" (a document I made set aside for notes) is opened.

If I could retrieve the name of the file while it is being opened (and only the 2nd instance of the application is visible) then I could just put into the code:

if documentbeingopened.name <> "notepad.doc" then
msgbox "message"
end if


(I always have my main document opened when I open this other document, via a button on a userform.)
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Skip that question. Made an embarrassing error. :(

Activedocument.name does retrieve the name of a document being opened. It's case-sensitive though.

Documents("NOTEPAD.doc").name works but not Documents("notepad.doc").name. (The file name is in all-caps.)
 
Upvote 0

Forum statistics

Threads
1,226,127
Messages
6,189,154
Members
453,526
Latest member
anyrandomtech

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