ReturnLastModifiedBy

returningby

New Member
Joined
Dec 24, 2015
Messages
4
Hey all,

I have been searching for the last 3 and a half hours so I finally admit I need some help. I currently have an excel document, and it has a list of hyperlink functions to a few different word documents. I wanted to track all of these word documents in excel. So I hyperlinked them, and made a field called "Last modified by". I found a great tool in the forums for a VBA script earlier:

Function ReturnLastModified(r As Range) As String
Dim temp
Application.Volatile True
temp = Split(r.Formula, Chr(34))(1)
If Dir(temp) <> "" Then ReturnLastModified = FileDateTime(temp)
End Function

Basically I have an excel document and I wanted to know when it was last modified. Worked great and the world was happy. So I started thinking, what if I used the nifty BuiltinDocumentProperties tool and grabbed the last author from these word documents? So I tried to alter and research the different syntax, but to no avail. The closest I got was similar scripts, but they always referenced the ActiveWorkbook. Seeing as how I am trying to point these hyperlinks, anything I do results in a #value error. Any help is appreciated. Thank you.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You can't access that property of a closed Word document natively in VBA. You either need to download a dsofile.dll from Microsoft that will allow your code to read that, or you'd need to automate Word and open the documents.
 
Upvote 0
Thank you,

While waiting for a response I had actually just read something about that very explanation. I am assuming that it can grab the last modified date because that information is published outside of the document itself. This project is on a work computer so I will not be able to download anything, but it was worth a shot anyway. Thank you.
 
Upvote 0
Except I didn't understand you correctly. I created a hyperlink in A1 to a word doc and used a UDF to get the last modified date in B1, isn't that what you want?

Excel 2013
AB
1HyperlinkLast modified
2My Cv01-Jun-15 17:59:28
Sheet3
Cell Formulas
RangeFormula
B2=LastmodData(A2)

UDF is something like
Code:
Function LastmodData(filepath As Range)
    If filepath.Hyperlinks.Count > 0 Then
        LastmodData = FileDateTime(filepath.Hyperlinks(1).Address)
    End If
End Function
 
Upvote 0
Thank you moment. I was accomplish what you showed in your example. However, after that information, I was looking for a way to also retrieve the last author who had made the modification, as opposed to just the time it was modified. Thank you again though for your time.
 
Upvote 0
Thank you moment. I was accomplish what you showed in your example. However, after that information, I was looking for a way to also retrieve the last author who had made the modification, as opposed to just the time it was modified. Thank you again though for your time.


I should think RoryA is right
 
Upvote 0
Hey RoryA,

After some more digging around the forums, I found some code that helped me a lot and funny enough it had been posted by you: http://www.mrexcel.com/forum/excel-questions/714431-get-username-if-file-already-open.html

In the thread you mentioned:

Code:
Function GetFileOwner(strfileName As String) As String
 
    Dim secUtil As Object
    Dim secDesc As Object
 
    Set secUtil = CreateObject("ADsSecurityUtility")
    Set secDesc = secUtil.GetSecurityDescriptor(strfilename, 1, 1)
    GetFileOwner = secDesc.Owner
 
End Function

This code actually works perfectly for what I need, however secdesc.owner seems to be pulling our company ID's which are just a string of numbers, as opposed to function like BuiltInDocumentProperties, that would pull actual usernames and whatnot.
I tried looking around, but couldn't find anything past secDesc.Owner, but do you know if there is a page with the parameters, so that you could drill down to secDesc.Owner.UserName, or secDesc.Owner.SID? Any variation I try just gives me a debug error, but I just might not be looking in the correct place for the variables. Thank you again for your help.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top