Time-limiting the use of an EXCEL file

Solved
RG14 Posted messages 77 Status Member -  
RG14 Posted messages 77 Status Member -
Hello,
I created a file with macros, calculation functions, etc. (Excel 2010)
Some cells are locked (protected sheet with code) to avoid accidentally disturbing the proper functioning.
I want to limit the usage of this file over time (for example, 1 week, or 1 month, etc.) for the people to whom I send it.
Can you help me with the procedure to apply?
Best regards
RG14

8 answers

  1. RG14
     
    Hello experts
    I’m sorry but all your submitted documents are rejected (product activation failure - pro?) I’m on 2010
    Your help is therefore useless. The level of protection I’m looking for is very basic .. just a usage restriction towards basic users. The file does not contain any special data but it is content that interests athletes..
    Thank you
    RG14
    3
    1. cs_Le Pivert Posted messages 8437 Status Contributor 730
       
      Another way: hide all sheets except one if the date has passed. Even if macros execution is disabled, access to all sheets will not be possible
      .
      Of course, you need to protect the macros.
      Go to Tools - VBAProject Properties - Protection and set the password

      Here is the code to put in ThisWorkbook:


      Option Explicit Dim datefin As Date Dim k As Integer Dim nom As String Private Sub Workbook_Open() nom = Left(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, ".") - 1) 'file name without extension datefin = "28 / 10 / 2018" 'set the last use date If datefin < Date Then MsgBox "The date has passed!", vbCritical, nom ThisWorkbook.Close Else MsgBox "You have: " & DateDiff("d", #10/28/2018#, Date) & " days left", vbInformation, nom 'set the last use date 'on open it is unmasked by macro, if not activated....... nothing For k = 1 To Sheets.Count Sheets(k).Visible = True Next End If End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) For k = 1 To Sheets.Count If Sheets(k).CodeName <> "Sheet1" Then 'adjust the name of the visible sheet Sheets(k).Visible = xlSheetVeryHidden 'sheets hidden even by right click End If Next End Sub 


      Here you go

      @+ The Pivert
      0
  2. RG14 Posted messages 77 Status Member 2
     
    Hello Pivert
    I have followed all the instructions and EVERYTHING works as intended. The opening time for rights is perfectly programmable, which restricts usage granted to "small profiteers" users
    thank you again for this particularly valuable help.
    best regards
    RG14
    1
  3. Anonymous user
     
    Hello,
    Maybe by putting a small hidden macro that would trigger on a certain date and erase the ranges of data and formulas...
    But I've never tried this manipulation!
    Best regards,
    Alain
    0
  4. cs_Le Pivert Posted messages 8437 Status Contributor 730
     
    I'm sorry, I can't assist with that.
    0
  5. RG14 Posted messages 77 Status Member 2
     
    I don't master it indeed (I am a DIY person...)
    I can't find Workbook_BeforeClose
    how to do it??
    thank you
    0
    1. cs_Le Pivert Posted messages 8437 Status Contributor 730
       
      Everything is explained in the workbook

      Press Alt F11 to access the editor

      Enter the password to access the macros found in ThisWorkbook

      Go to the top left and expand the tree to reach ThisWorkbook which you must select.

      You will see the code appear;

      This instruction is to be done for testing only (avoid destroying the workbook).

      Go to Sub creer_vbs on this line: f.write ("Dim nomfichier: nomfichier = ""Activation.xls"" ") & vbCrLf change the name and rename the workbook to this name afterwards after closing


      In the workbook to protect, also go to ThisWorkbook to set the validation date

      follow the instructions carefully

      see this in image

      https://www.excel-pratique.com/fr/vba/introduction.php

      @+
      0
  6. RG14 Posted messages 77 Status Member 2
     
    Here is where I am... see the screenshot link... not easy
    Also, I don't have anything on the workbook file but OK activation
    https://www.cjoint.com/c/HIrqn23bUfO
    RG14
    0
    1. cs_Le Pivert Posted messages 8437 Status Contributor 730
       
      It is necessary for you to open the workbook: Classeur_essai

      go to ThisWorkbook and copy all the code into your client workbook (ThisWorkbook) while simply modifying the last used date.

      In the workbook: Activation,

      it is not necessary to destroy it, delete this:

      Dim oWsh 'create_vbs ' to activate Set oWsh = CreateObject("Shell.Application") 'oWsh.ShellExecute Workbooks(ActiveWorkbook.Name).Path & "\delete_file.vbs" ' to activate Set oWsh = Nothing End Sub Private Sub creer_vbs() Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(Workbooks(ActiveWorkbook.Name).Path & "\delete_file.vbs", ForWriting, True) f.write ("On Error Resume Next") & vbCrLf f.write ("Set fso = WScript.CreateObject(""Scripting.FileSystemObject"")") & vbCrLf f.write ("Dim path") & vbCrLf f.write ("path = WScript.ScriptFullName") & vbCrLf f.write ("GetPath = Left(path, InStrRev(path, ""\""))") & vbCrLf f.write ("Dim nomfichier: nomfichier = ""Activation.xls"" ") & vbCrLf ' change the name and rename the workbook to this name after closing f.write ("Dim lieufichier: lieufichier = GetPath & nomfichier") & vbCrLf f.write ("If fso.FileExists(lieufichier) Then") & vbCrLf f.write (" fso.deletefile lieufichier") & vbCrLf f.write (" fso.deletefile path") & vbCrLf f.write ("WScript.echo "" [OK] The file has been deleted!"" ") & vbCrLf f.write ("Else") & vbCrLf f.write ("WScript.echo "" [ ] The file does not exist!"" ") & vbCrLf f.write ("End If") & vbCrLf f.write ("Set fso = Nothing") & vbCrLf f.write ("WScript.Quit") 


      It will still work

      There you go

      @+ Le Pivert
      0
  7. RG14
     
    Well, I don't think I'm up to the task... I can't open the workbook...
    0
    1. cs_Le Pivert Posted messages 8437 Status Contributor 730
       
      You need to open the Activation workbook, follow the instructions to make the Workbook_essai operational.

      There you go, I can't do more.

      See you later!
      0
  8. eriiic Posted messages 24581 Registration date   Status Contributor Last intervention   7 281
     
    Hello,

    know that you can always open a file while refusing to execute macros.
    From there, any protection will be in vain.
    Not to mention the cautious one who works on a copy...
    eric

    --
    By trying continuously, we eventually succeed.
    So the more it fails, the more chances we have that it works. (the Shadoks)
    In addition to the thank you (yes, yes, it happens!!!), remember to mark it as resolved. Thank you
    0
    1. cs_Le Pivert Posted messages 8437 Status Contributor 730
       
      For RG14, here is a simplified version:

      https://www.cjoint.com/c/HIsgeF7XMkQ

      Hello eriiic,

      open a file while refusing the execution of macros

      it's planned that the workbook closes

      work on a copy...

      this has no impact as well as renaming the workbook.
      The code that runs on opening looks for the date in the registry.

      The only way is to crack the VBA protection to access the macros.
      As I said from the start for an Excel pro it's quite easy!

      That's it

      @+ The Woodpecker
      0