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

    VBA Code (Word 2002)

    I just worked with a supplier-provided template which allowed me to view the code in the VBA editor, but it was impossible to edit the code. If I tried to type anything, a message popped up saying "Module can't be edited." The code was not locked from viewing, and I could review the modules at will. But I couldn't even add a comment. How is this "lock-down" added? Is there something in the Developer's Toolkit that does this?

    Richard Barrett

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: VBA Code (Word 2002)

    Was the template opened directly or was it available as an add-in. You can't edit code loaded as an add-in.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Australia
    Posts
    245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA Code (Word 2002)

    This has me perplexed too. I tried everything I could think of, but found nothing that could leave the VBA code showing but give a warning message that it "... can't be edited." I initially thought that maybe if the document had a 'modify' password and the code was protected by that but my tests didn't show that as the case. BTW, If the owner of the document does not want to allow the code to be modified (but viewed) then I can't see any real benefit of the protection, because any user could re-type the code or copy and paste into a new document.

    From my understanding there are no options on the VBA Tools menu that allow the code to be viewed but not modified. Unless the actual document has been modified with a COM Add-In that someone developed, I am unable to guess where to find out how to edit the code. In fact, the only reference in the Microsoft Office 2000 Visual Basic Programmer's Guide to this appeared to be about COM add-ins (Chapter 11, "Add-ins, Templates, Wizards, and Libraries". There was mention of locking a VBA project for viewing in Chapter 17 "Securing Office Documents and Visual Basic for Application Code".)

    The door is open to other suggestions.

  4. #4
    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: VBA Code (Word 2002)

    Since the VBE has its own object model, possibly it has an event model that can detect the activity of trying to type in a module?

    Having said that, I don't see it in the VBIDE events (related to commandbar buttons and changes to references). Does the template reference an add-in that could do this?

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

    Re: VBA Code (Word 2002)

    This was the PCDocs template for Word XP provided by Hummingbird. There are no References other than the usual.

    The reason for this, I would imagine, is that the publishers will support their own code, but not code that has been modified. They have no objection to customers who might want to copy the code, but the date and file size will make it obvious that this is not the "original."

  6. #6
    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: VBA Code (Word 2002)

    A usenet post suggested that message could indicate the template is read-only at the OS level and could be edited by removing that attribute. Does that work?

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

    Re: VBA Code (Word 2002)

    That was the first thing I chcked. It was not read-only.

  8. #8
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA Code (Word 2002)

    Just trying to catch up after some time away.

    When you are in the VBE, try clicking the Break button. Sometimes the code still thinks its running and won't let you edit it until you stop the execution.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  9. #9
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: VBA Code (Word 2002)

    Richard,

    Didn't see this thread until Brian revived it. Does the add-in by any chance contain a class module that is declaring application-level events? You can create an application-level event procedure that will respond to typing in Word, but I don't know if you can make it work in the VBE.

    Gary

  10. #10
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA Code (Word 2002)

    Another possibility, one that I just ran across this morning using VB6...

    If the original template was written using some form of source code control (probably VSS) then it may not be editable if the template was distributed without checking the modules out of the source code control.

    That or do you have it checkind into VSS? Same reasoning.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

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

    Re: VBA Code (Word 2002)

    Thanks.... That sounds like the best reasoning so far. The template is not read-only, and there are no references/add-ins other than the expected. I'm not familiar with VSS; what is it?

    Thanks,
    Richard

  12. #12
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA Code (Word 2002)

    VSS stands for Visual Source Safe. It is a Source Code control application, which can also be called a concurent versioning system.

    One of it's functions is to allow multiple developers to work on a single project by checking out only the bits they are working and allowing other developers to check out other bits.

    Another function is to allow you to "branch" your software. You can work on Version 2 of an application while still working on V1 all using the same base code.

    It can also act as a safety net. If you make some changes to your code that breaks other parts, you can revert to the last checked in code and basically undo all your changes.

    I'm sure I'm missing parts of what VSS can do. I'm not even sure if these descriptions go far enough.

    Maybe you'll get more info from those that have worked with VSS more. I'm just starting to use it myself.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Posting Permissions

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