VBA Access to File>Properties>Comment

strorg

Board Regular
Joined
Mar 27, 2002
Messages
112
I would like to read / write the File>Properties>Comment field via VBA code. A friend at work gave me his bit of code, but I don't have it with me.

Thanks...Tom
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Tom,

Here is a procedure in where You find the wanted property:

<PRE>


Private Sub<FONT color=blue> Workbook</FONT>_BeforePrint(Cancel<FONT color=blue> As</FONT> <FONT color=blue>Boolean</FONT>)

<FONT color=blue>Dim </FONT>dSkapad<FONT color=blue> As</FONT><FONT color=blue> Date</FONT>

<FONT color=blue>Dim </FONT>dSparadSenast<FONT color=blue> As</FONT><FONT color=blue> Date</FONT>

<FONT color=blue>Dim </FONT>sForfattare<FONT color=blue> As</FONT><FONT color=blue> String</FONT>

<FONT color=blue>Dim </FONT>sForetag<FONT color=blue> As</FONT><FONT color=blue> String</FONT>

<FONT color=blue>Dim </FONT>sHyperLank<FONT color=blue> As</FONT><FONT color=blue> String</FONT>

<FONT color=blue>Dim </FONT>sKommentarer<FONT color=blue> As</FONT><FONT color=blue> String</FONT>



dSkapad = ThisWorkbook.BuiltinDocumentProperties("Creation<FONT color=blue> Date</FONT>")

dSparadSenast = ThisWorkbook.BuiltinDocumentProperties("Last Save Time")

sForfattare = ThisWorkbook.BuiltinDocumentProperties("Author")

sForetag = ThisWorkbook.BuiltinDocumentProperties("Company")

sHyperLank = ThisWorkbook.BuiltinDocumentProperties("Hyperlink Base")

sKommentarer = ThisWorkbook.BuiltinDocumentProperties("Comments")



<FONT color=blue>With </FONT>ActiveSheet.PageSetup

.LeftHeader = "Skapad: " & dSkapad

.RightHeader = "Skapad av: " & sForfattare & "/" & sForetag

.LeftFooter = "Sparad senast: " & dSparadSenast

.RightFooter = sKommentarer & vbCr & sHyperLank

<FONT color=blue>End With</FONT>



<FONT color=blue>End Sub</FONT>


</PRE>

It´s in swedish and I´m too lazy to convert it to chines :wink:

Kind regards,
Dennis
 
Upvote 0

Forum statistics

Threads
1,216,414
Messages
6,130,456
Members
449,582
Latest member
Mengli

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