PDA

View Full Version : Macro to append hyperlink in Outlook 2007



gmr1999
04-12-2012, 07:35 AM
I have an add-in for MS Office 2007 that will auto-create an e-mail with a hyperlink to the stored MS Word, Excel, or PowerPoint it was triggered from. When the e-mail is created, it puts the filename as the displayed hyperlink text in the body of the e-mail, and places the cursor in the To: field. Unfortunately, I have to edit the hyperlink every time and add a short permission string to the end so that others can actually open/read the document.

Does anyone know if/how I could use a macro to automate this (i.e., open/edit the hyperlink so that I can append "&guest" to it)? I am a complete newbie, and the only thing I know on how to create macros is to record the steps I do, which apparently you can't do in Outlook.

I send my e-mails in HTML format. And if it makes any difference, I intended to place text both before and below the hyperlink, but if it makes it easier to make the hyperlink either the first thing in the body of the e-mail or the last, I can do that.

Thanks for any/all help!

gmr1999
04-12-2012, 02:48 PM
I'm continuing to fool around with this, and by searching this forums I'm a lot closer, and I'm hoping someone here can help put the finshing touches on this. I have below my current macro. At least it is running now, but it is overwriting the hyperlink address and changing it to just "&guest", which doesn't do any good. I think the key is either
1) objDoc.Hyperlinks.Add _ will overwrite the hyperlink address from scratch so maybe I should be using a different command
and/or
2) somehow I need to add lines to the macro that identifies the hyperlink address as a variable, then include that variable somehow in the objDoc.Hyperlinks.Add _ command.

If anyone has any suggestions, I would appreciate it.
Thanks


Sub AppendP8Guest()
' P8Link Macro
'
'
Dim objDoc As Word.Document
Dim objWord As Word.Application

Set objDoc = ActiveInspector.WordEditor
Set objWord = objDoc.Application
Set objRange = objDoc.Paragraphs(2).Range
Set objLink = objDoc.Hyperlinks.Add _
(objRange, "&guest", , , "")

End Sub

BrianMH
04-18-2012, 12:10 PM
You need to refer to the single hyperlink.

Something like
set objLink = objDoc.Hyperlinks(1).Address & "&guest"

gmr1999
04-19-2012, 01:04 PM
You need to refer to the single hyperlink.

Something like
set objLink = objDoc.Hyperlinks(1).Address & "&guest"
That did it, thanks!! Im new to these threads. Am i supposed to show it as solved/closed now, and how?

BrianMH
04-19-2012, 01:49 PM
Thread tools at the top of the page