Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    East Tennessee
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Macros (Word 2000)

    Recently got a new computer with XP Home, and am trying to use my old macros. I saved them and moved the file to my startup location.
    That seems good as far as it went. The macros work, and the toolbars are as I set them. Now however I have 2 instances of "Normal" that show in VBA editor. The lower one that seems to have the original macros in it will not alow me to open it. Any attempt says "Project Locked, project unviewable". If I make a new macro it shows up in the first (upper) Normal.

    What should I do get back to the usual operation?

    Thanks!
    Win 8, Firefox 16.0.2, Thunderbird 15.0.2

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macros (Word 2000)

    Normal.Dot should not be in Word's Startup folder, it should be in the templates folder. You now have 2 normal.dot templates, your old one in the Startup folder and a new one created for you by word in the Templates folder.

    Templates in the startup folder are known as Global templates. You can run Macros in them but you have to open them if you want to edit the macros. That is why the one you copied there shows as Locked and unviewable.

    I would recomment that you move the Normal.Dot in the startup folder to a normal user folder somewhere, then exit and restart word so it isn't loaded. Now open your old normal.dot (right click on it and choose Open) and use the Organiser (Tools > Templates and Add-ins > Organiser) to copy the old Macros to the new Normal.dot. Alternatively you could move the old normal.dot from the Startup folder to the templates folder, but this may lose any other customisation you have done.

    StuartR

  3. #3
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    East Tennessee
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Macros (Word 2000)

    Thanks! That got that straight.
    While I'm at it I would like to clean up my macro organization. I have some items that are modules but mostly proceedures in "NewMacros". I would like to take several of them where one proceedure calls another and form a module that would contain all the pieces rather than have them spread thru "NewMacros".

    I tried and can form a new module and copy the component pieces into it, but I can't find the way to rename the module so I can run it rather than the old one. I renamed the original macro so there should not be any conflict.
    Also I do not remember why some of the macros are individule modules. Can you tell me?

    Thanks again!
    Win 8, Firefox 16.0.2, Thunderbird 15.0.2

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

    Re: Macros (Word 2000)

    Activate the Visual Basic Editor.
    Make sure that both the Project Explorer (Ctrl+R) and the Properties window (F4) are visible.
    Select a module in the Project Explorer.
    There will be just one property in the Properties window: the name of the module. You can edit it there.

    In the olden times of WordBasic, a "macro" was a module containing a procedure called Main (plus other procedures if needed). You executed a macro by calling the name of the module; it would automatically execute Main. (This may not be entirely correct, my memory of WordBasic is fading fast. In fact, scrap "of WordBasic".)

    At least since Word 97, a macro is a procedure without arguments in a standard module. It can have any name and you call it by the name of the procedure. (If you have macros of the same name in different modules, you must prefix them with the module name when you call them: Module1.Test) You can pretty much organize macros any way you like - one big module with all macros, or many modules with only one macro each, or something in between. I think many programmers try to organize macros and other procedures and functions into functionally related groups.

  5. #5
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Macros (Word 2000)

    Hans,

    This is off the main subject, but I can't start a new thread when I'm at work, so I have to reply, but the top is at least "Macros". Anyway, how do I run a macro in another .DOT file? I'm assuming I might use a CALL statement, but I'm not sure how to CALL the macro from a different .DOT file. To be a little more specific, my main macro file is wsmenus.dot. Our company just installed some additional .DOT files to integrate our doc management system (Hummingbird DM). In the Hummingbird .DOT file is a macro called HumSave. I need to run that macro from my wsmenus.dot file. What's the best way to do this? A CALL statement or what?

    Thx.

    -Rich Belthoff

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

    Re: Macros (Word 2000)

    I don't know if this will work in a document management system environment, but you can call macros in an add-in / global template using Application.Run. Examples:

    If the name of the macro is unique:

    Application.Run "MyMacro"

    If the name of the macro is not unique, you can specify the module:

    Application.Run "MyModule.MyMacro"

    And if necessary also the name of the VBA project (each document and template has a VBA project name):

    Application.Run "MyProject.MyModule.MyMacro"

  7. #7
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Macros (Word 2000)

    That works. Thx. However, I didn't realize at first that the quotes were required. I thought you were just putting them around the macro name to show I was supposed to insert a name there. I figured this out when I recorded a macro running the other macro, which I suppose I should have done in the first place to figure this out, but I always forget the old adage to record sample code first before asking questions. ;-)

    Thx.

    -Rich Belthoff

  8. #8
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Macros (Word 2000)

    Oops, I have another question. Application.Run seems to cause the current macro to lose focus. In other words, Application.Run doesn't seem to act like a Call statement (which doesn't seem to work for running another macro). So, if I run the macro, it dies after the Application.Run statement. Is there a way to continue the original macro code execution after Application.Run executes?

    Thx.

    -Rich Belthoff

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

    Re: Macros (Word 2000)

    Application.Run shouldn't do that. The code should continue with the next statement when the called macro has finished running. Check carefully that no error occurs, and that the called macro doesn't contain a line with just

    End

    (this is different from End Sub, End If etc. - End by itself stops *all* code execution)

  10. #10
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Macros (Word 2000)

    Sadly, I can't check if the other macro has an "End" statement because it's in a protected Project (part of our doc management integration). If the Application.Run line ends my macro, I have to assume that something is ending it in the other macro. I guess I could put an "on error" statement around the application.run to see if it'll continue with the next statement of my macro. However, I suspect that the macro is just ending in the other Project and I won't be able to do anything about that. Oh well...

    Thx.

    -Rich Belthoff

  11. #11
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macros (Word 2000)

    Another option is to use Application.Ontime instead of Application.Run, this will run the other Macro in a completely separate context. Your Macro will continue running and the other Macro will run after the time delay you have specified.

    I don't know if this will help you, as this depends on whether you need to wait for the other Macro to complete.

    StuartR

  12. #12
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Macros (Word 2000)

    Thanks for the suggestion to use Application.Ontime, but that command would not run the other macro for some reason. I use "now" for "when" and the actual name of the macro in the protected project, but even though I didn't get an error, it wouldn't "call" the other macro. Oh well...

    Thx.

    -Rich Belthoff

  13. #13
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macros (Word 2000)

    Application.Ontime usually works fine. What does your code do after calling this?

    StuartR

  14. #14
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Macros (Word 2000)

    Thanks for the reply. Sorry for my delay in responding. Got tied up with other things. Anyway, here's my code:

    Sub CtrlKD()
    '
    ' SaveCloseDoc Macro
    ' Ctrl+K, D -- Save/Close Document
    '
    If Documents.Count > 0 Then 'Checks if Doc Open
    With ActiveDocument.Bookmarks 'Adds "QuickMark" bookmark
    .Add Range:=Selection.Range, Name:="QuickMark"
    .DefaultSorting = wdSortByName
    .ShowHidden = False
    End With
    ActiveDocument.Save 'Saves Open Doc
    ' Application.Run MacroName:="HumSave" 'Added for Hummingbird Integration
    ' Application.OnTime When:=Now, Name:="HumSave" 'Another attempt for Hummingbird
    ActiveDocument.Close 'Closes Open Doc
    Else 'Error Message
    vWSMCmd = "^KD" 'Sets value for vWSMCmd public variable
    Call NoDocOpenErrorMsg 'Calls Error Dialog
    End If
    End Sub

    For some reason, activedocument.save does NOT save the file to the DM system (I don't know where it goes, cause the "save" dialog flashes; must be to some temp file somewhere). So, I'm trying to get HumSave to work, which is the DM macro to save files to the DM system. BTW, the funny thing is, if I assign the standard Word command FileClose to my keystroke combination (^KD, the old WordStar key combination), the file saves to the DM system (but FileClose doesn't automatically save and close the file like my ^KD macro does). Anyway, the only thing that gets called after the HumSave line is activedocument.close, but the macro never gets there. When I used ontime, and stepped through the macro with F8, the macro would just stop at the ontime line without any error or other messages. The HumSave macro was never executed either. Thanks for any add'l insights you may have.

    -Rich Belthoff

  15. #15
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macros (Word 2000)

    It looks to me that you are closing the document before the Hummingbird software has a chance to run. Maybe you could add DoEvents after the Application.Ontime, to give it a chance to run. (I'm not sure this will work, but I am sure that you are closing the document too quickly).

    StuartR

Page 1 of 2 12 LastLast

Posting Permissions

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