Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-22-2012, 03:24 PM
jackj22 jackj22 is offline need to email hyperlink (filepath) from word doc Windows XP need to email hyperlink (filepath) from word doc Office 2007
Novice
need to email hyperlink (filepath) from word doc
 
Join Date: Feb 2012
Location: SC
Posts: 6
jackj22 is on a distinguished road
Default need to email hyperlink (filepath) from word doc

Hello..,. I need to email a hyperlink with the filepath from a word doc.

My googling skills have failed me, and thus far I haven't found success in the forums.

office 07

Thanks,
Jack
Reply With Quote
  #2  
Old 05-22-2012, 07:06 PM
macropod's Avatar
macropod macropod is offline need to email hyperlink (filepath) from word doc Windows 7 64bit need to email hyperlink (filepath) from word doc Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

hi Jack,

You've posted this in the Word vba forum, but there's nothing in your post to suggest that vba is involved. Please clarify.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-23-2012, 05:15 AM
jackj22 jackj22 is offline need to email hyperlink (filepath) from word doc Windows XP need to email hyperlink (filepath) from word doc Office 2007
Novice
need to email hyperlink (filepath) from word doc
 
Join Date: Feb 2012
Location: SC
Posts: 6
jackj22 is on a distinguished road
Default

My apologies. I'm looking for a vba solution (I can do similar things in excel vba).

This thread better expresses my desire:
https://www.msofficeforums.com/word-...hyperlink.html
Reply With Quote
  #4  
Old 05-23-2012, 10:35 AM
jackj22 jackj22 is offline need to email hyperlink (filepath) from word doc Windows XP need to email hyperlink (filepath) from word doc Office 2007
Novice
need to email hyperlink (filepath) from word doc
 
Join Date: Feb 2012
Location: SC
Posts: 6
jackj22 is on a distinguished road
Default

well, that thread's 10 months old without any response.

his question is:

To all,

Hopefully someone will be able to help.

I am trying to write a macro script to do the following...

Get the current filepath of the active word document. I can do this with a filepath = ActiveDocument.Path line.

Then I want to open up outlook and email that filepath as a hyperlink in the body of the text. Bascially so I can send the document to someone quickly but only the filepath and not the full document.

can anyone help?
Thanks.
Reply With Quote
  #5  
Old 05-24-2012, 11:03 PM
macropod's Avatar
macropod macropod is offline need to email hyperlink (filepath) from word doc Windows 7 64bit need to email hyperlink (filepath) from word doc Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It's still not clear what you want to do. ActiveDocument.FullName will return the document's full path and name, which you can then add to an email. For example, assuming early binding:
Code:
Sub Test()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
' Check if Outlook is running.  If it is not, start Outlook
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
    Set oOutlookApp = CreateObject("Outlook.Application")
    bStarted = True
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
  With oItem
    .Subject = "Test"
    .Body = "File://" & ActiveDocument.FullName
    .To = "jack22@someaddress.com"
    .Send
  End With
'  Close Outlook if it was started by this macro.
If bStarted Then
    oOutlookApp.Quit
End If
'Clean up
Set oItem = Nothing: Set oOutlookApp = Nothing
End Sub
(substitute a valid email address)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 05-24-2012, 11:25 PM
macropod's Avatar
macropod macropod is offline need to email hyperlink (filepath) from word doc Windows 7 64bit need to email hyperlink (filepath) from word doc Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See also: http://www.outlookcode.com/codedetail.aspx?id=1726
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 05-29-2012, 09:12 AM
jackj22 jackj22 is offline need to email hyperlink (filepath) from word doc Windows XP need to email hyperlink (filepath) from word doc Office 2007
Novice
need to email hyperlink (filepath) from word doc
 
Join Date: Feb 2012
Location: SC
Posts: 6
jackj22 is on a distinguished road
Default

This was extremely helpful. Thank you!

Using this your sample code plus some others, I am able to successfully execute doing the following:
PHP Code:
Private Sub CommandButton1_Click()
Dim bStarted As Boolean
'Dim oOutlookApp As Outlook.Application
'
Dim oItem As Outlook.MailItem
' Check if Outlook is running.  If it is not, start Outlook
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
    Set oOutlookApp = CreateObject("Outlook.Application")
    bStarted = True
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
  With oItem
    .Subject = "A/I: " & ActiveDocument.Name
    .Body = "<" & "File://" & ActiveDocument.FullName & ">"
    .To = "person1"
    .Cc = "the boss"
    .Importance = 2
    .Send
    '
.Display
  End With
'  Close Outlook if it was started by this macro.
If bStarted Then
    oOutlookApp.Quit
End If
'
Clean up
Set oItem 
NothingSet oOutlookApp Nothing

End Sub 
For some reason, I got a debug error on:
PHP Code:
'Dim oOutlookApp As Outlook.Application
'
Dim oItem As Outlook.MailItem 
..which is why I skip them. Any idea why? The code works fine as long as Outlook is open. For now, I've told my folks to make sure Outlook is open, otherwise it won't work.
Reply With Quote
  #8  
Old 05-29-2012, 04:06 PM
macropod's Avatar
macropod macropod is offline need to email hyperlink (filepath) from word doc Windows 7 64bit need to email hyperlink (filepath) from word doc Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You need to set a reference to Outlook in the vb editor. See under Tools|References.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink to direct email JaHoffman Word 5 07-05-2012 08:09 AM
Word macro to email hyperlink pooley343 Word VBA 0 07-20-2011 01:48 AM
Hyperlink to attached file in email message spino Outlook 0 08-05-2010 05:56 AM
cannot access hyperlink in email mdrvo Outlook 1 05-31-2010 12:35 PM
Cannot hyperlink from an email karen1430 Outlook 0 11-25-2007 03:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft