Consulting

Results 1 to 6 of 6

Thread: Solved: Hiding the source code...

  1. #1

    Solved: Hiding the source code...

    Hi all!

    I am new here in this f?rum, and I need a little help...

    I need to hide the source code of a Macro from the user, but i dont know how to do it . somebody can help me?

    Thanks

  2. #2
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Quote Originally Posted by Ricardovp
    Hi all!

    I am new here in this f?rum, and I need a little help...

    I need to hide the source code of a Macro from the user, but i dont know how to do it . somebody can help me?

    Thanks
    You can password protect the project.
    This will prevent most users from seeing the code.
    However, it is trivial to bypass password protection, so if you really wanna protect your code, you need to compile the code into a VB 6 DLL and then use a minimal amount of code within the actual Word template.

    For example, the code below is a module in my Word 2003 Normal template. The real code is in a VB 6 DLL that has the WordVBNormal class.

    Developing such classes has the added advantage of providing an opportunity to re-organize my code and eliminate duplicate code.

    For example, I must have at least umpteen different subs for registering/unregistering DLLs. Today, cowinkidentally, I finished creating a class that does everyting I need for (un)registering DLLs, so I'll register the DLL and get rid of the other code.

    [vba]
    Option Explicit
    Public clsWordVBNormal As WordVBNormal

    Public Sub AutoClose()
    SetupClass
    clsWordVBNormal.AutoClose
    End Sub

    Public Sub AutoExec()
    ' Runs only when global
    SetupClass
    clsWordVBNormal.AutoExec
    End Sub

    Public Sub AutoExit()
    SetupClass
    clsWordVBNormal.AutoExit
    End Sub

    Public Sub AutoNew()
    SetupClass
    clsWordVBNormal.AutoNew
    End Sub

    Public Sub AutoOpen()
    SetupClass
    clsWordVBNormal.AutoOpen
    End Sub

    Private Sub SetupClass()
    Dim docTemp As Word.Document
    If clsWordVBNormal Is Nothing Then
    If Documents.Count = 0 Then
    Set docTemp = Documents.Add(Visible:=vbFalse)
    End If
    Set clsWordVBNormal = New WordVBNormal
    clsWordVBNormal.SetClass Word.Application
    If Not (docTemp Is Nothing) Then
    docTemp.Close
    Set docTemp = Nothing
    End If
    End If
    End Sub
    [/vba]

  3. #3
    Hi Howard!

    Thanks for the Tip!!!

    How can I password protect the project?? I dont know the Word an VBA very well, actually it is my first project in VBA... its will work just to complement the program that I develop...

    Thanks

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    Hi Ricardo,

    just right-click Project(Documento1) then select Protect and "Bloquear projeto para exibi??o" (Block project for exibition). Insert and confirm a password. Ok its done.
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

  5. #5
    Thanks Paelo!

  6. #6
    Administrator
    VP-Knowledge Base VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    You are welcome. If sometime you rather you may even ask questions in portuguese in our non-english area.
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

Posting Permissions

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