+ Reply to Thread
Results 1 to 4 of 4

Protect VBAProject from within the code

  1. #1
    Ken Soenen
    Guest

    Protect VBAProject from within the code

    Is there any way to Protect/Unprotect the VBAProject from within the VB code
    rather than from the VisualBasic user interface?

    thanks,
    ken



  2. #2
    Tom Ogilvy
    Guest

    Re: Protect VBAProject from within the code

    Only using sendkeys.

    --
    Regards,
    Tom Ogilvy


    "Ken Soenen" <[email protected]> wrote in message
    news:[email protected]...
    > Is there any way to Protect/Unprotect the VBAProject from within the VB

    code
    > rather than from the VisualBasic user interface?
    >
    > thanks,
    > ken
    >
    >




  3. #3

    Re: Protect VBAProject from within the code

    You can keep the VB code from ever getting into the users workbook.
    How's that?

    1. Store the VB code in an AddIn,
    2. In the template or workbook, the one having the numbers add subs
    like these to remove the addin reference :


    Private Function ReferenceExists(reference As String) As Boolean
    Dim result As Boolean
    result = False

    On Error Resume Next
    result = Not Me.VBProject.References(reference) Is Nothing

    ReferenceExists = result
    End Function


    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
    Boolean)
    If ReferenceExists("MyExcellAddin") Then
    WorkbookUtils.RemoveReferences Me
    End If
    End Sub


  4. #4

    Re: Protect VBAProject from within the code

    This might help too.


    Private Sub Workbook_Open()
    If ReferenceExists("MyExcellAddin") Then
    ' We need to generate the report
    ReportUtils.AutoGenerateReport Me
    End If
    End Sub


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1