Use Custom Document Property to identify xls files not yet process

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro that goes through each spreadsheet in a folder and formats the
sheet.

I'd like to have the code first check to see if there is a Custom Document
Property and if so if it is set to True (this will tell the macro to close
the file and move to the next one - the current one has already been
formatted).

If it doesn't find the property (or if the property is set to false) it
would format the file, then add the property (or set it to true).

Can this be done via VB?

Thanks!
 
I have a macro that goes through each spreadsheet in a folder and formats the
sheet.

I'd like to have the code first check to see if there is a Custom Document
Property and if so if it is set to True (this will tell the macro to close
the file and move to the next one - the current one has already been
formatted).

If it doesn't find the property (or if the property is set to false) it
would format the file, then add the property (or set it to true).

Can this be done via VB?

Thanks!

Hello Robert,

Yes, it can. To check if the Workbook has any custom properties use
this code...

Cnt = ThisWorkbook.CustomDocumentProperties

If the Cnt = 0 then there are no Custom Document Properties.

To set a Custom Document Property use this code...

Sub AddCustomProperty()

Dim CustomProp As Object

Set CustomProp = ThisWorkbook.CustomDocumentProperties

With CustomProp
.Add Name:="User Name", LinkToContent:=False,
Type:=msoPropertyTypeString, Value:="Leith Ross"
End With

End Sub

Other TYPE constants are: msoPropertyTypeBoolean, msoPropertyTypeDate,
msoPropertyTypeFloat, msoPropertyTypeNumber, or msoPropertyTypeString.

Sincerely,
Leith Ross
 

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

Back
Top