Hyperlink in a macro comment

C

CollegeProf

I'm trying to set up macros to streamline grading essays, and I want to
include hyperlinks in comments that I have created as commands on a new menu.
I create each command as a macro that inserts a comment with text about the
error I've found, but I can't figure out how to include the hyperlink in the
text that is in the comment. When I record the macro, I can type in the URL
as part of the text in the comment, but it isn't hyperlinked. So, for
example, I've created a menu in Word called "Sentence Errors" and each
command inserts a comment regarding a particular type of error. Here is an
example fo the type of text I want to include in a comment:

You seem to be having some trouble shaping your sentences so that they read
clearly and smoothly. Try reading your words out loud. Often your ear can
help you determine if your writing is awkward. You should also visit
http://owl.english.purdue.edu/owl/resource/604/01 to review the various ways
in which sentences can be structured.

But I want the Purdue link to be active within the comment, so the students
can simply click it from their graded essays. Is this possible?
 
J

Jay Freedman

I'm trying to set up macros to streamline grading essays, and I want to
include hyperlinks in comments that I have created as commands on a new menu.
I create each command as a macro that inserts a comment with text about the
error I've found, but I can't figure out how to include the hyperlink in the
text that is in the comment. When I record the macro, I can type in the URL
as part of the text in the comment, but it isn't hyperlinked. So, for
example, I've created a menu in Word called "Sentence Errors" and each
command inserts a comment regarding a particular type of error. Here is an
example fo the type of text I want to include in a comment:

You seem to be having some trouble shaping your sentences so that they read
clearly and smoothly. Try reading your words out loud. Often your ear can
help you determine if your writing is awkward. You should also visit
http://owl.english.purdue.edu/owl/resource/604/01 to review the various ways
in which sentences can be structured.

But I want the Purdue link to be active within the comment, so the students
can simply click it from their graded essays. Is this possible?

If each of these comments consists of unchanging text, you should store each one
as an AutoText entry. Then your menu items can simply insert the appropriate
entry, which will contain the formatted URL. No macros are needed.

Start by entering the whole comment into an ordinary document, or selecting it
in a document where it already exists. Press Alt+F3 and give the entry a name.
Repeat that for each type of comment. The entries will be stored in your
Normal.dot template.

To make the menu entries, open the Tools > Customize dialog and select the
AutoText category. The names of the entries will appear in the Commands column.
Drag a name from that column and drop it on the menu of your choice.
 
C

CollegeProf

If each of these comments consists of unchanging text, you should store each one
as an AutoText entry. Then your menu items can simply insert the appropriate
entry, which will contain the formatted URL. No macros are needed.

Start by entering the whole comment into an ordinary document, or selecting it
in a document where it already exists. Press Alt+F3 and give the entry a name.
Repeat that for each type of comment. The entries will be stored in your
Normal.dot template.

To make the menu entries, open the Tools > Customize dialog and select the
AutoText category. The names of the entries will appear in the Commands column.
Drag a name from that column and drop it on the menu of your choice.

Ah, yes, I see how that would work. Using that system, I'd have to insert
the comment, then choose the autotext to fill the comment bubble. I was
using macros to create a one step process, recording inserting the comment as
part of the macro itself. Is there any way to edit a macro, in VBE perhaps,
to include a hyperlink in the text of a comment?
 
J

Jay Freedman

CollegeProf said:
Ah, yes, I see how that would work. Using that system, I'd have to
insert the comment, then choose the autotext to fill the comment
bubble. I was using macros to create a one step process, recording
inserting the comment as part of the macro itself. Is there any way
to edit a macro, in VBE perhaps, to include a hyperlink in the text
of a comment?

Of course there's a way, but it isn't anything the recorder will ever be
able to handle.

What I'll show below is a single subroutine (marked "Private" so it won't
appear in the list in the Macros dialog) that creates a comment and inserts
an AutoText entry into it. Below that are examples of macros that call the
subroutine, each macro passing a different AutoText entry name to be
inserted. These macros are the ones that you would add to the menu, giving
them appropriate names so the menu items will be understandable.

Private Sub InsertATComment(AutoTextEntryName As String)
Dim myComm As Comment
Set myComm = ActiveDocument.Comments.Add(Range:=Selection.Range)
NormalTemplate.AutoTextEntries(AutoTextEntryName) _
.Insert Where:=myComm.Range, RichText:=True
Set myComm = Nothing
End Sub

Sub InsertCommentA()
InsertATComment AutoTextEntryName:="CommentA"
End Sub

Sub InsertCommentB()
InsertATComment AutoTextEntryName:="CommentB"
End Sub

For example, if you've stored a comment as an AutoText entry with the name
SentenceFragment, you could make this macro to put in the menu:

Sub SentenceFragmentComment()
InsertATComment AutoTextEntryName:="SentenceFragment"
End Sub

Put the SentenceFragmentComment macro on the menu. When you select it, the
SentenceFragment comment will be inserted at the current selection.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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