Jump to content

MS Word: List of Constants


Recommended Posts

I'm looking for a list of VBA constants used by MS Word.

Someone on this forum once sent me a list of VBA constants used by Excel.

Now that I am starting to write scripts for Word, such a list would be very helpful.

If you don’t know what I mean by a list of constants, see the attachment (Constants.txt) from Enaiman at . The first few lines look like this

xl24HourClock,33
    xl3DArea,-4098
    xl3DAreaStacked,78
    xl3DAreaStacked100,79
    xl3DBar,-4099
    xl3DBarClustered,60
    xl3DBarStacked,61
    xl3DBarStacked100,62

The question is whether something similar is available for Word constants.

Any suggestions would be greatly appreciated.

Link to comment
Share on other sites

I'm not entirely sure what your objective is here but if you look in the help file there is a Word UDF setup to do functions within MS Word.

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Link to comment
Share on other sites

Are you talking about enumerations? For Word 2010 you find them here, for Word 2007 here.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi Water and Lurchman:

Thank you for responding.

The enumerations page is very helpful!

> I'm not entirely sure what your objective is here

Besides knowing what are the various settings (and that issue is now solved with the Enumerations list), I am wondering if there's an easy way to create a list of DIM statements for these settings (classes and members) that can be copied into my programs as needed (or be put in an #Include file).

So for example, the Selection.MoveRight method described at

http://msdn.microsoft.com/en-us/library/bb221936%28office.12%29.aspx

Syntax: expression.MoveRight(Unit, Count, Extend)

Regarding the first argument (Units), 16 units of measure can be specified.

(See http://msdn.microsoft.com/en-us/library/bb214015%28v=office.12%29.aspx )

For example...

wdCell 12 A cell.

wdCharacter 1 A character.

wdColumn 9 A column.

wdItem 16 The selected item.

wdLine 5 A line.

wdParagraph 4 A paragraph.

wdRow 10 A row.

Regarding the second argument (Count) ... This is a variant. There are no predefined values.

The third argument (Extend) has two possible settings, I believe...

wdMove 0 The selection is collapsed to the endpoint and moved to the right.

wdExtend 1 The selection is extended to the right.

So I am wondering if there's an easy way to create a list of DIM statements for these settings (classes and members). For example...

Dim $WdUnits
        Dim $wdCell         =  12
        Dim $wdCharacter    =  1
        Dim $wdColumn   =  9
        Dim $wdItem         =  16
        Dim $wdLine         =  5
        Dim $wdParagraph    =  4
        Dim $wdRow          =  10
    Dim $wdMoveExtend
        Dim $wdMove     =  0
        Dim $wdExtend   =  1

I believe this will make my programs more readable. For example..

; Example 1 
    $WdUnits = $wdCell
    $Count     = 1 
    $wdMoveExtend = $wdMove
    $oWordApp.Selection.MoveRight($WdUnits, $Count, $wdMoveExtend)

Of course it can be coded as follows.

; Example 2 
    $oWordApp.Selection.MoveRight(12, 1, 0)

    ; Example 3
    $Count     = 1 
    $oWordApp.Selection.MoveRight($wdCell, $Count, $wdMove)

However I find the 2nd example difficult to read.

And regarding the 3rd example... Although it is sufficiently descriptive, I prefer the 1st example because it forces me to think about what I am doing. I tend to clone code from here to there and often forget to change the variable names representing the arguments (inside the brackets), when necessary. With explicit assigments (eg $WdUnits = $wdCell) staring me in the face, it's less likely that I will forget to make the necessary changes.

So back to my original question....

Is there an easy way to create a list of DIM statements for these settings?

Does someone have an CSV file containing the various settings (classes and members) used by Word, similar to the list of constants used by Excel?

SEE ATTACHMENT #1 below

VBA-Constants_ForExcel.CSV.txt

(This is really a CSV file, but I've appended the TXT filetype so that it can be uploaded)

If there is such a file, a simple Excel formula can create the necessary DIM statements.

It could look something like the following CSV file that I just created (based on a few entries in that Enumerations list).

SEE ATTACHMENT #2 below

VBA-Constants_ForWord.CSV.txt

It contains the following columns

(A) Property/Method

(B)Class

(.C)Member

(D)Value

(E)Description

(F)AutoIT Variable - for classes (formula)

(G)AutoIT Constant - for members (formula)

Columns C and D are essential to my quest.

Column E would be very helpful.

Columns A and B would be nice to have.

SO ONCE AGAIN MY QUESTION IS....

Is there an easy way to create a list of DIM statements for these settings?

Any suggestions would be greatly appreciated.

VBA-Constants_ForExcel.CSV.txt

VBA-Constants_ForWord.CSV.txt

Link to comment
Share on other sites

See the "Find and harvest Enum constants for COM code" link in my sig.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...