S
steveblack2006
Hi
What I want to do is to ensure that the workbook is opened only from
the designated folder, in this case it is a folder in a mapped network
drive P:\. The code works as intended if I try to open the workbook
from my C:\ drive, ie. the workbook closes showing the message box. The
code is:
Const ServerPath As String = "P:\Documents and Settings\All
Users\Documents"
Private Sub Workbook_Open()
If ThisWorkbook.Path <> SeverPath Then
MsgBox "You are not allowed to open the workbook from the
current location"
ThisWorkbook.Close
End If
End Sub
However when the file is on the server, the workbook still closes.
Following command yielded the following:
Debug.Print ServerPath
Debug.Print ThisWorkbook.Path
Debug.Print ThisWorkbook.Path <> SeverPath
P:\Documents and Settings\All Users\Documents
P:\Documents and Settings\All Users\Documents
True
Why is If ThisWorkbook.Path <> SeverPath evaluating to true, eventhough
both ServerPath and ThisWorkbook.Path is same?
I am stumped. Any suggestions?
TIA.
What I want to do is to ensure that the workbook is opened only from
the designated folder, in this case it is a folder in a mapped network
drive P:\. The code works as intended if I try to open the workbook
from my C:\ drive, ie. the workbook closes showing the message box. The
code is:
Const ServerPath As String = "P:\Documents and Settings\All
Users\Documents"
Private Sub Workbook_Open()
If ThisWorkbook.Path <> SeverPath Then
MsgBox "You are not allowed to open the workbook from the
current location"
ThisWorkbook.Close
End If
End Sub
However when the file is on the server, the workbook still closes.
Following command yielded the following:
Debug.Print ServerPath
Debug.Print ThisWorkbook.Path
Debug.Print ThisWorkbook.Path <> SeverPath
P:\Documents and Settings\All Users\Documents
P:\Documents and Settings\All Users\Documents
True
Why is If ThisWorkbook.Path <> SeverPath evaluating to true, eventhough
both ServerPath and ThisWorkbook.Path is same?
I am stumped. Any suggestions?
TIA.