×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to determine the value of Microsoft Word 2010 constants

How to determine the value of Microsoft Word 2010 constants

How to determine the value of Microsoft Word 2010 constants

(OP)
This is in relation to my previous post modifying and formatting microsoft word document.

I'm working on some code from another developer who is no longer with the company. He created a script to find text, use HomeKey and EndKey, and move things around. To learn more since I can't ask him outright, I Googled the following line in hopes for a breakdown in how it works:

objWrd.Selection.HomeKey 6, 0 

The closest thing I can find on any of the many web sites I've visited is this for VBA:

Selection.HomeKey Unit:=wdStory, Extend:=wdMove 

Any idea how the previous developer may have modified the latter to get the VBScript version?

RE: How to determine the value of Microsoft Word 2010 constants

Probably started with the object model documentation … https://docs.microsoft.com/en-us/office/vba/api/ov...

For example the documentation for the Selection object describes the Extend parameter of the HomeKey method as a member of the WdMovementType enumerations. That enumeration is documented as:

Name      Value Description
wdExtend  1     The end of the selection is extended to the end of the specified unit.
wdMove    0     The selection is collapsed to an insertion point and moved to the end of the specified unit. Default. 

It is unfortunately perhaps less clear or explicit that the Unit parameter is a member of the wdUnit enumeration (documented here)

RE: How to determine the value of Microsoft Word 2010 constants

(OP)
I guess I've got a lot to learn. I've used constants for the FileSystemObject, and those were easy to find. I guess you need to know where/how to look.

I was able to decipher how to insert a bit of text within a space between two paragraphs and make the insertion invisible.

I used this to count how many paragraphs are in the letter:

iParCount = objWrd.ActiveDocument.Paragraphs.Count 

Then, I had to put an 8 point space after the date within the letter. This is because if I tried to enter text within either of the two spaces between the date and the salutation, it replaced the space entirely. This space had to be left in there, and 8 point, along with the 12 point text and another 8 point space made it seem like I had done nothing. Here's how:

objWrd.ActiveDocument.Paragraphs(6).SpaceAfter = 8  ' 8 point space
objWrd.ActiveDocument.Paragraphs(7).Range.Font.ColorIndex = 8   ' wdWhite = White color
objWrd.ActiveDocument.Paragraphs(7).Range.Text = "DPS$$$PKG"
objWrd.ActiveDocument.Paragraphs(7).SpaceAfter = 8 

Still trying to figure out how to reformat the rest of the letter, but I'm learning. :)

RE: How to determine the value of Microsoft Word 2010 constants

(OP)
Sadly, the company security on my computer won't let me download the file.

I'm trying to figure out how to shift a block, or line, of text a few spaces to the right or to the left. I thought this would work, but it just removed the first word in the line of text:

objWrd.ActiveDocument.Paragraphs(18).LeftIndent = 5 

I wish there was more clear documentation on how to manipulate the Word DOM and what the best practices are.

RE: How to determine the value of Microsoft Word 2010 constants

(OP)

UPDATE: I found some code on how to shift a block of text. Instead of using ".LeftIndent", this is what I used:

objWrd.ActiveDocument.Paragraphs(18).IndentCharWidth 1 

This moved the lines of text (showing in the DOM as paragraphs) over to the right about 1.5 characters.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close