VBA question battery - free to answer any number

T

Tommy Svensson

Hi all,

Need some basic help with the following issues:

1) Programmatically, how do I set the view of a document to "Normal"?

2) Is it possible to change the color of a selection (the normal black one)
and how can I change it programmatically?

3) I have a macro that resizes a document window, I would like the text to
wrap nicely in the window so that the horizontal scrollbar is not visible
(or, there's no need to croll to the right). How can I achieve this?

4) I have an undo macro but it does not seem to do it all. It inserts a
bookmark every time I do a macro operation and then when I press ctrl-z I
intercept the undo command and backtrack all the bookmarks. Is there no way
to undo a bunch of operations all at once without having to press ctrl-z
multiple times?

5) How can I retrieve the word that is currently under the mouse pointer in
a word document? (i.e without clicking)

6) How do I intercept a right click on a word in a word document and/or
customize the context menu?

7) Is it possible to store invisible information on every word in a
document? What I mean is this:

Generated/tagged Word document:
----------

Hi, my name is <data age=27>Tommy</data> and this is a text string in a Word
document.

-----------

Can I right click on Tommy and in the context menu add the age of Tommy? Of
course, the <data> tag is a pseudo tag for invisible data connected to
Tommy.

Thx,

/Tommy
 
M

Malcolm Smith

2) Is it possible to change the color of a selection (the normal black
one)
and how can I change it programmatically?

Look at the .Font object of the Selection range.
 
J

Jonathan West

Tommy Svensson said:
Hi all,

Need some basic help with the following issues:

1) Programmatically, how do I set the view of a document to "Normal"?

ActiveWindow.View.Type = wdNormalView
2) Is it possible to change the color of a selection (the normal black one)
and how can I change it programmatically?

You mean change the color of the reverse black background of selected text?
I don't think there is a way to do that within VBA.
3) I have a macro that resizes a document window, I would like the text to
wrap nicely in the window so that the horizontal scrollbar is not visible
(or, there's no need to croll to the right). How can I achieve this?

ActiveDocument.ActiveWindow.View.WrapToWindow = True

(You must be in normal view for this to work)
4) I have an undo macro but it does not seem to do it all. It inserts a
bookmark every time I do a macro operation and then when I press ctrl-z I
intercept the undo command and backtrack all the bookmarks. Is there no way
to undo a bunch of operations all at once without having to press ctrl-z
multiple times?

ActiveDocument.Undo n

where n is the number of operations you want to undo.
5) How can I retrieve the word that is currently under the mouse pointer in
a word document? (i.e without clicking)

There isn't a way to do that within VBA as far as I know.
6) How do I intercept a right click on a word in a word document and/or
customize the context menu?

You can customize al menus by going to Tools, Customize. If you scroll down
the list of toolbars you will see one called "Shortcut menus" There are
several shortcut menus, and different ones appear depending on which part of
the document you are over when you right-click.
7) Is it possible to store invisible information on every word in a
document? What I mean is this:

Generated/tagged Word document:
----------

Hi, my name is <data age=27>Tommy</data> and this is a text string in a Word
document.

-----------

Can I right click on Tommy and in the context menu add the age of Tommy? Of
course, the <data> tag is a pseudo tag for invisible data connected to
Tommy.

There are a variety of possibilities here, but which one will suit you
depends on how thoroughly invisible you need the information to be. The
first idea that comes to mind is to insert comments at the appropriate
places.
 
J

Jay Freedman

Tommy said:
4) I have an undo macro but it does not seem to do it all. It inserts
a bookmark every time I do a macro operation and then when I press
ctrl-z I intercept the undo command and backtrack all the bookmarks.
Is there no way to undo a bunch of operations all at once without
having to press ctrl-z multiple times?

See http://groups.google.com/[email protected]
7) Is it possible to store invisible information on every word in a
document? What I mean is this:

Generated/tagged Word document:
----------

Hi, my name is <data age=27>Tommy</data> and this is a text string in
a Word document.

-----------

Can I right click on Tommy and in the context menu add the age of
Tommy? Of course, the <data> tag is a pseudo tag for invisible data
connected to Tommy.

You may want to look into generating your documents using XML. Word 2002 has
some bolt-on XML capabilities, and Word 2003 has much better support.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top