+ Reply to Thread
Results 1 to 5 of 5

How to set macro to open word file equal to cell contents of a specific cell

  1. #1
    Registered User
    Join Date
    02-01-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    44

    How to set macro to open word file equal to cell contents of a specific cell

    Hi all,

    I'm looking to develop a macro which would enable me to open a Word file based on the contents of a specific cell. The cell contents will be dynamic based on other factors within the excel sheet, and contains the full filepath of the file I am looking to open.

    It is essentially a Hyperlink request, but as I am getting an error message relating to an OLE action (which I have established a code to disable) when I use the hyperlink route, I'm looking to go the VBA route to fulfil this request.

    Does anyone have any advice for me in this regard? Any help as always gratefully received.

    Thank you.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: How to set macro to open word file equal to cell contents of a specific cell

    ligerdub,

    Assuming the cells you want to act as hyperlinks are in column A and they only ever contain Word docs, give this a try:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    02-01-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: How to set macro to open word file equal to cell contents of a specific cell

    Thanks for the response Tiger.

    Do you know know do I assign this macro to an object or shape? When I look to assign macro to a button I don't have the option to select the above?

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: How to set macro to open word file equal to cell contents of a specific cell

    That code is a Worksheet_SelectionChange event and should be placed in the appropriate worksheet module. So if the items are in column A of Sheet1, then the code would go in the Sheet1 module. Then just click on a cell in column A of sheet1 and that will trigger the SelectionChange event which will cause the code to be run.

    If you need a stand alone macro that you can assign to a button, and the cell containing the Word doc filepath is in cell A1, give this a try:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-01-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: How to set macro to open word file equal to cell contents of a specific cell

    Ah I see, I hadn't been clicking on the cell. That's a nice feature.

    Thanks a lot for that, worked a treat, very much appreciated sir.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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