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?
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
0
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.
0
[ fanpages ]IT Services ConsultantCommented:
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

[ 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"

?
0
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

0

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
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.