+ Reply to Thread
Results 1 to 15 of 15

Hyperlink a cell to a .msg file from a button

  1. #1
    Registered User
    Join Date
    02-21-2017
    Location
    Castelford
    MS-Off Ver
    2013
    Posts
    89

    Hyperlink a cell to a .msg file from a button

    Hi all,

    I'm new to this forum and was hoping someone could help me with a task i'm trying to complete.

    I have an excel workbook which is a register of all emails sent and received on a project, currently I have to manually search our server for the customer and then the project file and input the information (Date sent/to/from/hyperlink to .msg file) into the workbook.

    I was wondering if anyone has created a code to input some of this information automatically (HYPERLINK & DATE SENT or RECEIVED). To hyperlink to the .msg it will have to route into the server and find the .msg based on the email number which is in Colum A.

    The .msg files would be saved in a 'correspondence' folder in either a 'Received' or 'Sent' Folder

    I have created the workbook already and have attached for your reference.

    Regards
    Nathan
    Attached Files Attached Files
    Last edited by nathandavies9; 02-21-2017 at 12:04 PM.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Hyperlink a cell to a .msg file from a button

    Welcome to the forum

    Thanks for providing the workbook, but would you be able to give more detail? What should the code do exactly? It seems the hyperlink in column D should be a network location, is that a mapped drive or just a location? assuming D: for the drive for the moment, does that mean the link would be "D:\Customer\Project\1.msg"? Where does the date info come from, and where should it be put? What about To and From? What will tigger putting this information in?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    02-21-2017
    Location
    Castelford
    MS-Off Ver
    2013
    Posts
    89

    Re: Hyperlink a cell to a .msg file from a button

    Hi Arkadi,

    Thanks for the response

    when an email is either sent or received by someone they will go to the register and press either button, this will then look at the server(which is a mapped drive - \\servername\projects) where the latest email should have been saved in either sent or received, it will then put a hyperlink in column D and rename the .msg to the next number based on column A and insert the date based on today (Cell A1). all other information should will be inputted manually, unless it could be extracted from the email?

    I'm new to code but I spend hours inputting this information into registers daily and wanted to speed things up.

    Thanks

  4. #4
    Registered User
    Join Date
    02-21-2017
    Location
    Castelford
    MS-Off Ver
    2013
    Posts
    89

    Re: Hyperlink a cell to a .msg file from a button

    Thinking about it I could get away completely with the sent and received folders and just have one Correspondence folder so to not confuse matters.

    I have attached a new example

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Hyperlink a cell to a .msg file from a button

    Nathan, you say you want the .msg renamed, but how would the code know what the original name of the msg was, to find the right one and rename it?

  6. #6
    Registered User
    Join Date
    02-21-2017
    Location
    Castelford
    MS-Off Ver
    2013
    Posts
    89

    Re: Hyperlink a cell to a .msg file from a button

    Very good point!

    When you save an email it saves it based on the Subject, what if we put the subject into Column C - Email Details and then rename it after?

  7. #7
    Registered User
    Join Date
    02-21-2017
    Location
    Castelford
    MS-Off Ver
    2013
    Posts
    89

    Re: Hyperlink a cell to a .msg file from a button

    Or manually rename it when we save it.

    the other option would be to create a macro in Outlook to save the email automatically to the correct folder and then input the information into excel from outlook, but I'm assuming this would be a lot of code

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Hyperlink a cell to a .msg file from a button

    This may all seem simple but...

    I assume the list will keep expanding and it is a permanent log? How would the code know which emails to rename, and which have been taken care of already (for example there is a date already in column E)
    What if 4 items are entered in the list, but 2 are sent and 2 are received? How will the code know this, or are you counting on the user(s) to know they can only do sends or receipts at a time, or are you only wanting the code to work with the most recent entry in the whole list?

  9. #9
    Registered User
    Join Date
    02-21-2017
    Location
    Castelford
    MS-Off Ver
    2013
    Posts
    89

    Re: Hyperlink a cell to a .msg file from a button

    Yes, the list will keep expanding throughout the lifecycle of a project.

    the code wouldn't know which one to rename unless we could select the email, or if we rename the email when we save it from outlook. we would differentiate the sent or received based on Column B and F and this would be down the user to understand.

    the code would know which emails have been taken care once the email has been hyperlinked because the date is the date of the email (either sent or received)

  10. #10
    Registered User
    Join Date
    02-21-2017
    Location
    Castelford
    MS-Off Ver
    2013
    Posts
    89

    Re: Hyperlink a cell to a .msg file from a button

    Hi Arkadi,

    I have had a good think about what is required based on your comments and have put together a new solution, I don't think what I require can be completed in excel but any comments would be greatly appreciated.

    1. When an email is either received or sent you go to a the macros and press save
    2. When you press save a text input box will appear where you can insert the customer name and project number
    3. this will then search through my works server to find the folder and open the correspondence folder
    4. once the folder has been open the email will be saved in that location with the date and time as a prefix to the subject.
    5. once this has been done an excel workbook will be opened and information from the email will be saved in the excel document (email addresses/subject/dates/To and From/Hyperlink to email)
    6.once this has been completed it will ask if you want to keep the email in your inbox or sent items Yes to keep no to delete.

    Thanks in advance
    Nathan

  11. #11
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Hyperlink a cell to a .msg file from a button

    To have a macro save the email that is sent/received you'd need some code in Outlook I believe. I have done some minor coding in Excel that controls an Outlook object, but never within outlook itself. You would be able to use code to send an email via outlook and presumably to save it in the process, but this would not apply to received emails, just sending.


    I am hoping someone more knowledgeable with coding in Outlook can take over here since it may be possible to do a lot of this in Outlook, perhaps it can have all the code required to input the data into excel at the same time without needing any code in the excel sheet. I will post in another thread we have for requesting help from our other experts.

    I will also monitor here to see if I can help further, but I really think most of this can be done from the outlook side.

  12. #12
    Registered User
    Join Date
    02-21-2017
    Location
    Castelford
    MS-Off Ver
    2013
    Posts
    89

    Re: Hyperlink a cell to a .msg file from a button

    Arkadi,

    Thanks for your help with this its much appreciated.

    Nathan

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Hyperlink a cell to a .msg file from a button




  14. #14
    Registered User
    Join Date
    02-21-2017
    Location
    Castelford
    MS-Off Ver
    2013
    Posts
    89

    Re: Hyperlink a cell to a .msg file from a button

    snb,

    Thanks for the post I will have a look and see if I can find anything.

  15. #15
    Registered User
    Join Date
    02-21-2017
    Location
    Castelford
    MS-Off Ver
    2013
    Posts
    89

    Re: Hyperlink a cell to a .msg file from a button

    Hi Arkadi,

    I have managed to get the code to work for saving emails into a folder located on a server folder from outlook.
    [CODE][/ Option Explicit
    Function BrowseForFolder(Optional OpenAt As Variant) As Variant
    Dim ShellApp As Object
    Set ShellApp = CreateObject("Shell.Application"). _
    BrowseForFolder(0, "Please choose a folder", 0, OpenAt)

    On Error Resume Next
    BrowseForFolder = ShellApp.self.Path
    On Error GoTo 0

    Set ShellApp = Nothing
    Select Case Mid(BrowseForFolder, 2, 1)
    Case Is = ":"
    If Left(BrowseForFolder, 1) = ":" Then GoTo Invalid
    Case Is = "\"
    If Not Left(BrowseForFolder, 1) = "\" Then GoTo Invalid
    Case Else
    GoTo Invalid
    End Select
    Exit Function

    Invalid:
    BrowseForFolder = False
    End Function

    Public Sub SaveMessageAsMsg()
    Dim oMail As Outlook.MailItem
    Dim objItem As Object
    Dim sPath As String
    Dim dtDate As Date
    Dim sName As String
    Dim enviro As String
    Dim strFolderpath As String

    enviro = CStr(Environ("FILEDIRECTORY"))

    strFolderpath = BrowseForFolder(enviro & "\\NEWBENSON\Projects")

    For Each objItem In ActiveExplorer.Selection
    If objItem.MessageClass = "IPM.Note" Then
    Set oMail = objItem

    sName = oMail.Subject
    ReplaceCharsForFileName sName, "-"

    dtDate = oMail.ReceivedTime
    sName = Format(dtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
    vbUseSystem) & Format(dtDate, "-hhnnss", _
    vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName & ".msg"

    sPath = strFolderpath & "\"
    Debug.Print sPath & sName
    oMail.SaveAs sPath & sName, olMSG

    End If
    Next

    End Sub

    Private Sub ReplaceCharsForFileName(sName As String, _
    sChr As String _
    )
    sName = Replace(sName, "'", sChr)
    sName = Replace(sName, "*", sChr)
    sName = Replace(sName, "/", sChr)
    sName = Replace(sName, "\", sChr)
    sName = Replace(sName, ":", sChr)
    sName = Replace(sName, "?", sChr)
    sName = Replace(sName, Chr(34), sChr)
    sName = Replace(sName, "<", sChr)
    sName = Replace(sName, ">", sChr)
    sName = Replace(sName, "|", sChr)
    End Sub

    CODE]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Hyperlink button from a cell value
    By aviko150 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-12-2016, 12:57 PM
  2. Macro/Hyperlink button that will go to a specific Page in a PDF File
    By gamurphy64 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2016, 10:44 AM
  3. Replies: 0
    Last Post: 02-18-2015, 06:17 AM
  4. [SOLVED] Auto hyperlink file from specific folder after enter file name in cell
    By satputenandkumar0 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2014, 06:11 AM
  5. [SOLVED] Button to open folder based on cell hyperlink adress
    By mirenoba in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-11-2014, 05:39 AM
  6. Hyperlink from file based on cell value
    By bencarey in forum Excel General
    Replies: 2
    Last Post: 10-31-2011, 02:48 PM
  7. Hyperlink button to a specific cell in excel
    By JayWes in forum Excel General
    Replies: 1
    Last Post: 07-21-2005, 07:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1