"Comments" Loction under properties? Using VBA

Hatcheda

Active Member
Joined
Dec 8, 2005
Messages
354
ActiveWorkbook.BuiltinDocumentProperties("comments") is the location for comments in Excel

Can anyone tell me the location in Word?
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Change ActiveWorkbook to ActiveDocument.
 
Upvote 0
No.:)

The standard events for a document are Open, New and Close.

And I don't mean to be rude but last time I looked this was an Excel forum.:)
 
Upvote 0
I am building a properties macro for Excel and Word. The Final step needed before changing this to a before save event will be to check if the first user applied a ";" to the end of their Comment.

Currently it will check if a comment is there an apply 'updated' if it is, if not, it will apply 'created' -both function correctly. The only other consideration will be that someone else created the document and didn't apply a ';' -which is required at the end of every entry. To do this I will need a check that pulls the last character of the current entry

Please help with this if you can.

Code:
Sub PropertiesProject()
Dim Username: Dim Time, CurrentComments As String
Time = Format(Now(), "Short Date")
Username = Environ("USERNAME")
CurrentComments = ActiveDocument.BuiltInDocumentProperties("comments").Value
If CurrentComments = "" Then
ActiveDocument.BuiltInDocumentProperties("comments") = Time & " Created By " & Username & ";"
Else
ActiveDocument.BuiltInDocumentProperties("comments") = CurrentComments & " " & Time & " Updated By " & Username & ";"
End If
End Sub

I believe it should looks like this. -Of course I will need the formula for the last digit :-)

Code:
Sub PropertiesProject()
Dim Username: Dim Time, CurrentComments As String
Time = Format(Now(), "Short Date")
Username = Environ("USERNAME")
CurrentComments = ActiveDocument.BuiltInDocumentProperties("comments").Value
If CurrentComments = "" Then
ActiveDocument.BuiltInDocumentProperties("comments") = Time & " Created By " & Username & ";"
Else

If (Last Digit) <> ";" Then
ActiveDocument.BuiltInDocumentProperties("comments") = CurrentComments & "; " & Time & " Created By " & Username & ";"
Else

ActiveDocument.BuiltInDocumentProperties("comments") = CurrentComments & " " & Time & " Updated By " & Username & ";"
End If: End If
End Sub
 
Upvote 0
Well if you want to get the last character of any string use this.
Code:
LastChar = Right(MyString, 1)
 
Upvote 0
Thank you! Works well!
Code:
Sub PropertiesProject()
Dim Username: Dim Time, CurrentComments, LastChar As String
CurrentComments = ActiveWorkbook.BuiltinDocumentProperties("comments").Value
LastChar = Right(CurrentComments, 1)
Time = Format(Now(), "Short Date")
Username = Environ("USERNAME")
If CurrentComments = "" Then
ActiveWorkbook.BuiltinDocumentProperties("comments") = Time & " Created By " & Username & ";"
Else
If LastChar <> ";" Then
ActiveWorkbook.BuiltinDocumentProperties("comments") = CurrentComments & "; " & Time & " Updated By " & Username & ";"
Else
ActiveWorkbook.BuiltinDocumentProperties("comments") = CurrentComments & " " & Time & " Updated By " & Username & ";"
End If: End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,345
Messages
6,184,394
Members
453,229
Latest member
Piip

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