VBA to Identify shared files

I have encountered problems when running Macros where an error is displayed because the file is Shared and the code will not work with a shared file. i.e. UnMerge

Is there a piece of VBA code that will, when it opens a file, identify the fact that the file is shared and say something like, "the file you are opening is Shared and will cause problems with this Macro. Please save a file that is not shared"
JagwarmanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
HI,

in the ThisWorkbook module pls try

Private Sub Workbook_Open()
If Me.MultiUserEditing Then
    MsgBox "Problems with this shared File"
End If
End Sub

Open in new window

Regards
JagwarmanAuthor Commented:
Unfortunately that did not work.

Just in case my question was not clear [I do have this problem of not explaining myself clearly]

In my macro I am opening other files so it is the file that my macro will open that will be shared not the file I am in with the macro.
[ fanpages ]IT Services ConsultantCommented:
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

[ fanpages ]IT Services ConsultantCommented:
In my macro I am opening other files so it is the file that my macro will open that will be shared not the file I am in with the macro.

How are you opening the "other files"?

Using syntax like...

Workbooks.Open Filename:="AnotherFile.xlsx"

?
Rgonzo1971Commented:
then maybe

set Wb = Workbooks.Open(Filename:="MyFile.xlsx")
If Wb.MultiUserEditing Then
    MsgBox "Problems with this shared File"
    Exit Sub
End If

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JagwarmanAuthor Commented:
fanpages, yes that is how I am opening them
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.