Use DocProps in a change declaration

C

chris w

Below is a change declaration I have in a sheet, is it possible to have a
similar change declaration using docProps in another cell? So when the
change is made to cell "I7" the date is put in "J7" and the current author is
put in "L7"

I tried to copy what I have below except change = Now to =
DocProps("author") and that didnt work.

Private Sub Worksheet_change(ByVal Target As Range)

If Not Intersect(Target, Range("I7")) Is Nothing Then
Range("J7") = Now
End If

End Sub
 
B

Bob Phillips

Private Sub Worksheet_change(ByVal Target As Range)

If Not Intersect(Target, Range("I7")) Is Nothing Then
Range("J7") = Now
Range("L7").Value = ActiveWorkbook.BuiltinDocumentProperties("author")
End If

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
C

chris w

Worked like a charm, thanx

Where can I find a "dictionary" of VB code or the pop up entries that come
up to help complete the code?
 
C

chris w

link dosent work.

but I have run into a glitch with this function, kinda,

What this tool is doing is I have a button that runs a macro to update links
to the sheet and makes a change to the cell "I7" so "J7" shows when the
update macro was run and I want "L7" to show who ran the update. Using
author, it puts my name in regardless of who (which computer) has the sheet
open. I have another cell that shows who the last author is, but last author
dosent work unless the person saves the sheet before running the update.

I suppose I can have as part of the macro to save sheet?
 
B

Bob Phillips

chris w said:
link dosent work.

Try this

http://msdn.microsoft.com/library/d...n-us/modcore/html/deovrmicrosoftexcel2000.asp
but I have run into a glitch with this function, kinda,

What this tool is doing is I have a button that runs a macro to update links
to the sheet and makes a change to the cell "I7" so "J7" shows when the
update macro was run and I want "L7" to show who ran the update. Using
author, it puts my name in regardless of who (which computer) has the sheet
open. I have another cell that shows who the last author is, but last author
dosent work unless the person saves the sheet before running the update.

I suppose I can have as part of the macro to save sheet?

No need. I should have thought of that when I was writing it. Updated
version

Private Sub Worksheet_change(ByVal Target As Range)

If Not Intersect(Target, Range("I7")) Is Nothing Then
Range("J7") = Now
Range("L7").Value = Environ("username")
End If

End Sub


Bob
 
C

chris w

Bob, your help has been spot on, thank you,

but I believe I may be getting in over my head. The last string change to =
environ("username"), works perfectly, except I realize now my user name on my
XP machine shows "Owner" on the win 98 machines shows nothing. Changing the
"Owner" designation looks to get messy.
 
B

Bob Phillips

Chris,

Here is an alternative. I can't test it as I don't have Win98 or 95, but it
shoudl work. It does mean that on the 98 machines, you need to ensure that
the Excel user is defined (Tools>Options and on the general tab, set5 the
User Name box).

Private Sub Worksheet_change(ByVal Target As Range)
Dim sOS As String
Dim sSystem As String

If Not Intersect(Target, Range("I7")) Is Nothing Then
sOS = Application.OperatingSystem
Select Case True
Case InStr(1, sOS, "NT 5.01") > 0: sSystem = "XP"
Case InStr(1, sOS, "NT 5.00") > 0: sSystem = "2000"
Case InStr(1, sOS, "NT 4.00") > 0: sSystem = "NT4"
Case InStr(1, sOS, "4.10") > 0: sSystem = "Win98"
Case InStr(1, sOS, "4.00") > 0: sSystem = "Win95"
End Select

Range("J7") = Now
If sSystem = "Win98" Or ssyetm = "Win95" Then
Range("L7").Value = applicationusername
Else
Range("L7").Value = Environ("username")
End If
End If

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top