Consulting

Results 1 to 12 of 12

Thread: List of Word macro commands

  1. #1

    List of Word macro commands

    I need a list of all macro commands for MS Word. The list available under Tools>Macro can't be copied. Can I find a list elsewhere?

    On that same line, is Steven Roman's book on VBA in Word available on the web (as is his book on Excel)?

    papillon

  2. #2
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    992
    Location
    Welcome to VBA Express!

    Quote Originally Posted by papillon
    ... is Steven Roman's book on VBA in Word available on the web?
    "On the web", as in free, no. But is is available from Amazon.

    It's dated a good bit (1999), but a lot of the code in the book is still working even in Word 2010.

    If you're just starting out, I'd invest, at the very least, in Roman's book. But there are probably some books in the $50 range that will probably serve you better, since there are so many new features in 2007/2010.

    You can always paruse Microsoft's site. They do have some very good articles and tutor's for VBA. Navigate to the developers page nad start searching.

    Do you have a particular project in mind?

    David


  3. #3

    Word macro commands

    It's interesting that Roman's Excel book is on the web but his Word one isn't.

    I'm not exactly starting out - I've written some large and sophisticated macros for Excel, including fully formatting the output from other software, but I've never worked in Word.

    I need to take an existing newsletter, add names and addresses from a list, and print each one and I want to do similar things with letters. I know about MailMerge but I want to run this from Panorama database software so the user doesn't have to do anything (I'm writing for decidedly non-computer-literate users).

    Any ideas on the availability of a list of commands?

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    "I need a list of all macro commands for MS Word. The list available under Tools>Macro can't be copied. Can I find a list elsewhere?"

    "Any ideas on the availability of a list of commands?"

    Please be clear. The list of macros (Tools > Macros) is the list of written macros for whatever template/document named in the "Macros in:" dropdown (the default is All templates and documents).

    Commands usually refer to internal commands.

    Whar - exactly - are you trying to get?

    I am not sure what you mean by "commands".

    Looking at the object model is always helpful.

  5. #5

    VBA commands for Word

    In Tools>Macro, I select Macros in: Word commands from the pop-up under the list of macros that exist. This gives me a scrolling list of "commands", beginning with AcceptAllChangesInDoc. It's obviously not a complete list because it doesn't include, for example, Save or SaveAs.

    In the statement: ActiveDocument.SaveAs FileName:= etc., I would call the SaveAs component a command. It's VBA nomenclature may be something different (a method?).

    What I'd like is a table of such words so that I can know what options I have (whilst acknowledging that the full family of commands.code-words is huge). One of the big problems I found in VBA for Excel (on both Mac and PC), was that I'd record an action, then play back the macro and get an error message rejecting the recorded procedure - this happened several times.

    In such a case, I need alternative code but I have no idea what the code might be. I have used forums and web searches for help in this and I find that there are more ways to skin a cat in VBA than you can count and that many of the code snippets on the web simply don't work (people don't always say what version they're written for and VBA can vary wildly across versions). I prefer not to spend money on VBA guide books - I've found several of them very frustrating and unhelpful.

    I guess my primary objective is to have as much reliable info to hand as possible to speed up my coding process. maybe I should just keep stumbling around in the gloom - it works out OK in the end

  6. #6
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    992
    Location
    Quote Originally Posted by papillon
    I need to take an existing newsletter, add names and addresses from a list, and print each one and I want to do similar things with letters. I know about MailMerge but I want to run this from Panorama database software so the user doesn't have to do anything (I'm writing for decidedly non-computer-literate users).

    Any ideas on the availability of a list of commands?
    You can look at any 'Calling database from Word' macro and get a general idea of how you might be able to work this from Panorama.

    I still think using Word mail merge will be the way to go. You can program it using VBA, and it will be quite sublime to the user. I'm just not sure whether it will be better to Panorama->Word or Word->Panorama.

    As far as a list of commands in reference to how Excel handles things, we preach using the Range object, and not Selection. (Word records macro exclusively in Selection.) If you want the user to be unaware of what's going on behind the scenes, then Range is your friend.

    Another difference is that Word flows and is not defined by Row/Column. If you want to move down seven lines and pick the fifth word, it may or may not be in that same location the next time you run the macro.

    However, your requirement for a simple data insertion should be relatively straight forward if you compare it to other Access merge examples I've seen: define the merge fields in your newsletter, and letters, connect with the database and print.

    Does Panorama offer any connection string examples?

    David


  7. #7
    OK, I'll have a close look at using Mail Merge - I just have no idea how to program it - is the whole process likely to record adequately?

    I've always used Range in programming Excel - it's what to put next that's my problem. For instance, is there a GoToTopOfDocument-type command? Is there a GoToLine n command? A WhatLineAmIOnNow?, etc?

    What do you mean by a connection string example. Typically, in Panorama, I open an existing Word doc which contains an AutoOpen macro which does all the work - it gets parameters from another Word doc newly created by Panorama and does whatever I want. The Panorama-VBA interface is really cool (after you've put in a squillion hours working out how to do it). I've actually written a tutorial showing fellow Panorama users how best to do it, thus saving them all the heartache.

  8. #8
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    992
    Location
    Quote Originally Posted by papillon
    For instance, is there a GoToTopOfDocument-type command? Is there a GoToLine n command? A WhatLineAmIOnNow?, etc?
    Nope, well, yes, but you're still thinking like Excel. Check out this link. Going to the top of the document is unnecessary for this merge. GotoLine is still 'too Excel' Think in paragraphs.

    I'm probably getting in over my head! (Where's Graham Mayor when you need him?) Here's another example of using Access from Word.

    What do you mean by a connection string example. ...

    I open an existing Word doc which contains an AutoOpen macro which does all the work - it gets parameters from another Word doc newly created by Panorama and does whatever I want.
    And can you view the code in the document? It might give us a starting point.

    David


  9. #9
    And can you view the code in the document? It might give us a starting point.[/QUOTE]

  10. #10
    I can certainly view it - in the case of my Excel projects, I wrote it! This is what I expect to do in Word.

    I'll leave this discussion for the time - I need to do some homework.

    many thanks for your time and help.

  11. #11
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    992
    Location
    OK, then, how do you setup the data connection with Parorama?

    David


  12. #12
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    "In Tools>Macro, I select Macros in: Word commands from the pop-up under the list of macros that exist. This gives me a scrolling list of "commands", beginning with AcceptAllChangesInDoc. It's obviously not a complete list because it doesn't include, for example, Save or SaveAs."

    Ummm, actually, it does. But, like all the other commands, it just lists then. You can not see the coding behind it (no Edit button).

    "For instance, is there a GoToTopOfDocument-type command? Is there a GoToLine n command? A WhatLineAmIOnNow?, etc?"

    If you are talking about the cursor (the Selection), and assuming you are, in fact, in the MainStory - there a number of "Stories" - then to go to the start of the document:
    [vba]
    Selection.HomeKey Unit:wdStory)[/vba]

    As for: WhatLineAmIOnNow? Well...yes...but....
    [vba]
    Dim r As Range
    Set r = ActiveDocument.Range(Start:=0, _
    End:=Selection.Range.Start)
    MsgBox r.ComputeStatistics(wdStatisticLines)
    [/vba]

    This gives the number of "lines" from the cursor back to the start of the document. The but...comes from the fact that I think you (as Tinbendr suggests) may be too Excel-entric. Say you have:

    One
    Two
    Three
    Whatever blah blah.

    If you put the cursor at the "h" of Whatever, it returns 4, the fourth line. If the cursor is at the "W", it will return 3, the third line. The is a very good reason for this.


    Worse yet, take your:

    One
    Two
    Three
    Whatever blah blah.

    You have the cursor (Selection) at the "W", and the code returns 3. Now put a 3 x 3 table between the "Three" and the "Whatever". Still keeping the cursor at the "W", what do you think the "line" number is?

    The answer is: 9

    And never mind: "Is there a GoToLine n command? "

    Yes, sort of.
    Last edited by fumei; 09-07-2010 at 09:52 AM.

Posting Permissions

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