Results 1 to 7 of 7

Thread: Word Document Security

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    41

    Word Document Security

    Try this one on for size,

    My boss has asked me if there is a way that he can create a word document that can only be viewed x number of time and then automatically delete itself, or have the file "disappear" after x days.

    Has anyone else attempted this or seen anything like this?

    Thanks.

    Kid Coke

  2. #2
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    Re: Word Document Security

    I think you could do that, but it wouldn't be foolproof, e.g. the user can disable macros or just hold the shift key while opening the doc. and I believe your startup VBA would be skipped.

    Word VBA lets you save a variable with the document.
    Checkout ActiveDocument.Variables(index)
    So you could keep a counter or drop-dead date in there to check against. I've haven't tried it.

    Deleting a doc while it's open may not work, but you could delete its contents and do an immediate save.
    "The wise man doesn't know all the answers, but he knows where to find them."
    VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Word Document Security

    About all you could do is if the x number of openings are reached, then close the doc without saving the changes.
    VB Code:
    1. ActiveDocument.Close False
    I think the way MS does it with its beta versions is by making a registry entry and disables
    the toolbars when the time is reached. No, you cant delete the document from WOM VBA.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    41

    Re: Word Document Security

    Thanks people!

    I figured that using a macro to delete the document contents on x date followed by a save is the only way to pull this off.

    Do you think there are otherways to make "self destructive" files (excel, acrobat, etc)

    Let me know what you guys think.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Word Document Security

    Any way you try it, the file will need to be closed. You cant delete it from Word VBA.
    Why go to all this trouble to delete it? If you prevent them from opening it after x number of times that should make them
    want to delete it on their own.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    41

    Re: Word Document Security

    Rob .... I guess I didn't read your post carefully.

    If the person were to copy the document with a new name and they open it will the limitations still exist?

    Personally, I don't understand why my boss is going to all this trouble to protect this document but it seems important to him.

    Thanks.

  7. #7
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: Word Document Security

    you could create a DOS batch file.

    e.g. word doc opens, VBA calls DOS batch file, which closes word, and deletes the file.

    this will work even if they copy the file to another location as the DOS batch will always be in the same location with the same name and it is this that will do the deletion.

    still doesnt help if the user disables VBA.

    just a thought
    if you fail to plan, you plan to fail

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width