Results 1 to 10 of 10
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    'invisible' code (VBA Word 2003)

    I've been told that there's a way to "hide" the code (modules, forms, class modules) in a VBA project (Word .dot file). The compiled code is contained in the template project, but if the project is opened in the VBA editor, nothing is visible. Can anyone tell me what product is used develop code in this way?

    Thanks,
    Richard Barrett

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'invisible' code (VBA Word 2003)

    Select Tools | Project Properties (in the Visual Basic Editor)
    Activate the Protection tab.
    Tick the check box, and enter a password (twice).
    Click OK.
    Next time you open the template or a document based on it, the code will be hidden.

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: 'invisible' code (VBA Word 2003)

    Thanks... I guess I should have been more specific. I know that "hiding" the code in the way you have mentioned is an option. I understand that there is another way, where no password is applied, and therefore no password to "crack".

    I have actually seen such a template that one of my clients had in use. Alt-F11 takes you to the VBE as usual. With the .dot file open, you can click on the "+" next to the project in the project exporer, and it turns to a "-".... there is no dialog asking for the password. There is simply nothing there.

    I was wondering if the Developer version of Office included something to do this, or perhaps VB Studio.

    Richard

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'invisible' code (VBA Word 2003)

    If you install a .dot file as an add-in (global template), you can't view the code. But itf you open the template using File | Open..., you CAN view the code.

    Perhaps someone else knows of a better way, short of creating a DLL using the Office Developer Extensions.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: 'invisible' code (VBA Word 2003)

    There might be a way to "hack" the DOT file so that the uncompiled source modules are difficult to access while the compiled code still runs, but I've never read about any tool to do it.

  6. #6
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: 'invisible' code (VBA Word 2003)

    I'm wondering if this might have been done (I saw such a template at a client's office a while back) with Visual Studio. Perhaps the template referenced a DLL, and the template's toolbar connected to functions in the DLL. Even with such a scenario, I'd expect to see SOMETHING in a code module. I'm going to try to get another peek at the template and have a look at References. Interestingly, after I poked around in the "empty" VBE, an email came from the publisher of the template saying that the Digital Signature was now invalid. So the code was not only invisible, it could phone home!

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'invisible' code (VBA Word 2003)

    Sounds like a VSTO solution. If you look at the custom document properties (file, properties), are there any there like:
    _AssemblyLocation0 or _AssemblyName0?
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  8. #8
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: 'invisible' code (VBA Word 2003)

    Thanks very much. I've been trying to evaluate what VSTO offers over VBA solutions. Can you tell me anything from your own experience? I've read quite a bit, and I see that there are a number of differences in code/syntax, but it all makes good sense. There seem to be some very useful code enhancements (StringWirter, Try.. Catch... Finally construct, etc). Most of what I've found is on VS .Net with libraries to be downloaded for use with Office XP. I imagine VSTO is an improvement? Does VSTO actually create .dot files? I suppose that's my main question.

    Thanks again for your reply. Richard

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'invisible' code (VBA Word 2003)

    All I know is that the two custom properties are what ties the VSTO code to a document.
    What I also know, is that there are quite some issues regarding International settings of Office/WIndows and the VSTO interfacing to Office. Maybe next version these will be ironed out.
    Since 95 percent of my clients are still on versions older than 2003, I have no inclination to further persue VSTO as yet. But that may change rapidly...
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  10. #10
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: 'invisible' code (VBA Word 2003)

    Thanks. I'm in the same position... the majority of my clients use Office XP. That is starting to change, and I want to learn as much as I can. Richard

Posting Permissions

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