Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Verifying path fails for no apparent reason..Clueless

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Verifying path fails for no apparent reason..Clueless

Bangs head on table.

That was the only module I didnt have Option Explicit... :-(

Thanks Ardus for pointing it out.

Now there is another thing I just noticed. If I disable Macro on
opening I can still view the Worksheet. I am wondering if there is a
workaround to that...?

Anyway thanks..




Ardus Petus wrote:
Typo:
If ThisWorkbook.Path < SeverPath Then


should be:
If ThisWorkbook.Path < ServerPath Then


The error would be easier to find if you used Option Explicit

HTH
--
AP

a écrit dans le message de news:
...
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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
customized toolbars reset for no apparent reason can't find .xlb JT Spitz Setting up and Configuration of Excel 7 October 20th 08 08:04 PM
#NAME? error for no apparent reason... Monomeeth Excel Worksheet Functions 4 September 15th 08 08:22 AM
Workbooks.Open fails when using a full network path.... [email protected] Excel Programming 3 May 19th 06 05:09 PM
Excel is behaving strangely for no apparent reason. canyondude New Users to Excel 4 January 10th 06 12:07 AM
Excel resizes images with no apparent reason Carlos Lozano Excel Programming 2 August 24th 05 10:23 PM


All times are GMT +1. The time now is 09:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"