PC Review


Reply
Thread Tools Rate Thread

Disable spreadsheet when copied to incorrect file path or differen ip address

 
 
Schatzi
Guest
Posts: n/a
 
      28th Apr 2011
I have password protected the worksheets and VB code and disabled the
saving function. Still, the program can be copied and pasted to
another location. Is there a way to implement a macro that will disble
the spread sheet if is in an incorrect file location or an incorrect
IP address?
 
Reply With Quote
 
 
 
 
GS
Guest
Posts: n/a
 
      28th Apr 2011
Schatzi wrote :
> I have password protected the worksheets and VB code and disabled the
> saving function. Still, the program can be copied and pasted to
> another location. Is there a way to implement a macro that will disble
> the spread sheet if is in an incorrect file location or an incorrect
> IP address?


You can check 'ThisWorkbook.Path' on startup for the expected string
value and if not correct then 'ThisWorkbook.Close'!

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
Reply With Quote
 
Schatzi
Guest
Posts: n/a
 
      28th Apr 2011
I tried using the code:
MyFullName = ThisWorkbook.FullName
ActiveWorkbook.Close False

I'm not sure where I need to import the correct path. I have this in
the Auto_open sub.

On Apr 28, 3:59*pm, GS <g...@somewhere.net> wrote:
> Schatzi wrote :
>
> > I have password protected the worksheets and VB code and disabled the
> > saving function. Still, the program can be copied and pasted to
> > another location. Is there a way to implement a macro that will disble
> > the spread sheet if is in an incorrect file location or an incorrect
> > IP address?

>
> You can check 'ThisWorkbook.Path' on startup for the expected string
> value and if not correct then 'ThisWorkbook.Close'!
>
> --
> Garry
>
> Free usenet access athttp://www.eternal-september.org
> ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
Reply With Quote
 
GS
Guest
Posts: n/a
 
      28th Apr 2011
on 4/28/2011, Schatzi supposed :
> I tried using the code:
> MyFullName = ThisWorkbook.FullName
> ActiveWorkbook.Close False
>
> I'm not sure where I need to import the correct path. I have this in
> the Auto_open sub.
>
> On Apr 28, 3:59*pm, GS <g...@somewhere.net> wrote:
>> Schatzi wrote :
>>
>>> I have password protected the worksheets and VB code and disabled the
>>> saving function. Still, the program can be copied and pasted to
>>> another location. Is there a way to implement a macro that will disble
>>> the spread sheet if is in an incorrect file location or an incorrect
>>> IP address?

>>
>> You can check 'ThisWorkbook.Path' on startup for the expected string
>> value and if not correct then 'ThisWorkbook.Close'!
>>
>> --
>> Garry
>>
>> Free usenet access athttp://www.eternal-september.org
>> ClassicVB Users Regroup! comp.lang.basic.visual.misc


You should know where the project is to be stored. It's not some value
that you retrieve somehow; it's a deliberately decided location.

You could store the correct path in a constant, the Registry, or a file
in the same folder as the project. In fact, you don't even need to
store the path because you could use a dummy file in the same folder
and check if that exists at startup. Users will not likely know that
this file is needed and so would copy/saveas the workbook only.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
Reply With Quote
 
Schatzi
Guest
Posts: n/a
 
      29th Apr 2011
On Apr 28, 5:09*pm, GS <g...@somewhere.net> wrote:
> on 4/28/2011, Schatzi supposed :
>
>
>
>
>
> > I tried using the code:
> > MyFullName = ThisWorkbook.FullName
> > ActiveWorkbook.Close False

>
> > I'm not sure where I need to import the correct path. I have this in
> > the Auto_open sub.

>
> > On Apr 28, 3:59*pm, GS <g...@somewhere.net> wrote:
> >> Schatzi wrote :

>
> >>> I have password protected the worksheets and VB code and disabled the
> >>> saving function. Still, the program can be copied and pasted to
> >>> another location. Is there a way to implement a macro that will disble
> >>> the spread sheet if is in an incorrect file location or an incorrect
> >>> IP address?

>
> >> You can check 'ThisWorkbook.Path' on startup for the expected string
> >> value and if not correct then 'ThisWorkbook.Close'!

>
> >> --
> >> Garry

>
> >> Free usenet access athttp://www.eternal-september.org
> >> ClassicVB Users Regroup! comp.lang.basic.visual.misc

>
> You should know where the project is to be stored. It's not some value
> that you retrieve somehow; it's a deliberately decided location.
>
> You could store the correct path in a constant, the Registry, or a file
> in the same folder as the project. In fact, you don't even need to
> store the path because you could use a dummy file in the same folder
> and check if that exists at startup. Users will not likely know that
> this file is needed and so would copy/saveas the workbook only.
>
> --
> Garry
>
> Free usenet access athttp://www.eternal-september.org
> ClassicVB Users Regroup! comp.lang.basic.visual.misc- Hide quoted text -
>
> - Show quoted text -


I was able to use this code and it works great. It does check where
the file is stored and makes sure it matches up with where I want it
to be stored:

Private Sub Workbook_Open()
FullPath = ThisWorkbook.FullName
If FullPath <> "c:\test.xls" Then
MsgBox "This file can only be accessed from the server: " +
FullPath, vbExclamation, "Access Denied"
ActiveWorkbook.Close False
End If
End Sub

Thanks for your help.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting/using the File path of a spreadsheet B Baggins Microsoft Excel Programming 1 11th Feb 2008 08:10 PM
Incorrect autotext for path and file name =?Utf-8?B?S2F5?= Microsoft Word Document Management 1 5th Nov 2007 11:39 PM
Unable to delete a file folder (incorrect path) rico.thespian@gmail.com Windows XP New Users 3 23rd Sep 2006 05:48 PM
Incorrect resolution of path to XLA file when user has roaming prf =?Utf-8?B?Q2FybCBM?= Microsoft Excel Programming 0 21st Apr 2005 08:02 PM
Address Book disappears when *.pst file is copied Tim Dees Microsoft Outlook 3 23rd Nov 2003 10:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:21 PM.