MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

preventing distribution

  Asked By: Daryl    Date: Feb 07    Category: MS Office    Views: 671

Do any of you have ideas of how I could prevent distribution of an excel
workbook using VBA.



2 Answers Found

Answer #1    Answered By: Ibtihaj Akhtar     Answered On: Feb 07

I used:

Sub proVerifyPathName()
'display message box with pathname for verification,then use
PathName below
'MsgBox "Path: " & ActiveWorkbook.Path & _
'Chr(13) & "Name: " & ActiveWorkbook.Name & _
'Chr(13) & "FullName: " & ActiveWorkbook.FullName
'after using above, use displayed pathname to verify
authenticity of file
If (ActiveWorkbook.FullName <> "P:\user name\VancoKinetics8.xls")
MsgBox "Warning, " & Application.UserName & vbCrLf & _
"Unauthorized copies of this program file are not allowed."
& _
Chr(13) & "We will hunt you down!", vbOKOnly +
vbCritical, "Unauthorized Copy"
ActiveWorkbook.Close False
End If

End Sub

First uncomment the three lines (MsgBox, Chr(13), Chr(13)) to get
your pathname. Then recomment them so they don't keep popping up,
and change the P:\user name\VancoKinetics8.xls to whatever your
pathname is. This only allows it to be run from the designated drive
& folder.

Answer #2    Answered By: Leonardo Costa     Answered On: Feb 07

forgot to tell you, I have the following in the ThisWorkbook object:

Private Sub Workbook_Open()
'go to sub to verify it is authorized copy of file
'loads and shows frmVancomycin when Excel opens
Load frmVancomycin
End Sub

And, of course, you can change the comments in the message box if
someone tries to run from somewhere else.
Let me know if this works for what you want.

Didn't find what you were looking for? Find more on preventing distribution Or get search suggestion and latest updates.