Case Sensitive Custom Property Macro

I could use a hand figuring this one out. I'm working on a macro to set and enter all of our standard custom properties. Problem is, there isn't a lot of consistency with being case sensitive with old data and with VB being so case sensitive I can only get my macro to work for the right cases.

This is how it's pulling the custom property info now.

**** CheckDateCompleted = CurrentDoc.CustomInfo2("", "DateCompleted") ****

If the property is DateCompleted, it will show up in the dialog box and enter correctly. If the property is DATECOMPLETED it won't.

How do I get around this to make it non case sensitive? I was thinking about pulling them as a list, and outputting that list to an array and forcing the array values to uppercase and working off that, but I'd need some help to do that. I understand how it all works, I just don't know enough about visual basic to pull it off. I'm having similar problems trying to force the text pulled from the existing properties to uppercase and outputting them back when saving to uppercase.

Thanks, James

Reply to
James Spisich
Loading thread data ...

You can try to read both "versions", first the lowercase and then the uppercase (simple IF-THEN-ELSE) to see which one exists. And then use UCase function to output them in the right way

Markku

Reply to
Markku Lehtola

One option is to loop thru all the custom properties and look for the one you want. Test by using the UCASE or LCASE function to convert the strings to all upper or lower case characters in the test.

Reply to
cempamj

Here's what I got working. I pulled all of the properties in the current file, then did an if then else compare to the properties I wanted. Then deleted whatever was left over than the ones I wanted added with the last 2 lines of the If chain (greater & less than null). And the Ucase function as setup below works fine. Just have to put it during the call, and before the set to force it to come in uppercase, and to save uppercase.

********************************************

Option Compare Text ' Sets all string comparisons to be case insensitive

' Get custom properties CustomCount = CurrentDoc.GetCustomInfoCount2("") CustomNames = CurrentDoc.GetCustomInfoNames2("")

For j = 0 To CustomCount - 1 CustomName = CustomNames(j)

If StrComp(CustomNames(j), "DateCompleted") = 0 Then CheckDateCompleted = CurrentDoc.CustomInfo2("", CustomNames(j)) ' get current completed date ElseIf StrComp(CustomNames(j), "Material") = 0 Then CheckMaterial = CurrentDoc.CustomInfo2("", CustomNames(j)) ' get current material ElseIf StrComp(CustomNames(j), "PartShtSize") = 0 Then CheckPartShtSize = CurrentDoc.CustomInfo2("", CustomNames(j)) ' get current sheet size ElseIf StrComp(CustomNames(j), "PartBase") = 0 Then CheckPartBase = CurrentDoc.CustomInfo2("", CustomNames(j)) ' get current base # ElseIf StrComp(CustomNames(j), "Description") = 0 Then CheckDescription = CurrentDoc.CustomInfo2("", CustomNames(j)) ' get current description ElseIf StrComp(CustomNames(j), "DrawnBy") = 0 Then CheckDrawnBy = CurrentDoc.CustomInfo2("", CustomNames(j)) ' get current detailer ElseIf StrComp(CustomNames(j), "DesignedBy") = 0 Then CheckDesignedBy = CurrentDoc.CustomInfo2("", CustomNames(j)) ' get current designer ElseIf StrComp(CustomNames(j), "CheckedBy") = 0 Then CheckCheckedBy = CurrentDoc.CustomInfo2("", CustomNames(j)) ' get current checker ElseIf StrComp(CustomNames(j), "Revision") = 0 Then CheckRevision = CurrentDoc.CustomInfo2("", CustomNames(j)) ' get current revision ElseIf StrComp(CustomNames(j), "Finish") = 0 Then CheckFinish = CurrentDoc.CustomInfo2("", CustomNames(j)) ' get current finish ElseIf StrComp(CustomNames(j), "DrawingSize") = 0 Then FieldType = CurrentDoc.DeleteCustomInfo(CustomNames(j)) ' delete DrawingSize property ElseIf StrComp(CustomNames(j), "PartNo") = 0 Then FieldType = CurrentDoc.DeleteCustomInfo(CustomNames(j)) ' delete PartNo property ElseIf StrComp(CustomNames(j), "") = 1 Then FieldType = CurrentDoc.DeleteCustomInfo(CustomNames(j)) ' delete All other properties ElseIf StrComp(CustomNames(j), "") = -1 Then FieldType = CurrentDoc.DeleteCustomInfo(CustomNames(j)) ' delete All other properties End If Next j

' Force Properties to Uppercase CheckDateCompleted = UCase(CheckDateCompleted) CheckMaterial = UCase(CheckMaterial) CheckPartShtSize = UCase(CheckPartShtSize) CheckPartBase = UCase(CheckPartBase) CheckDescription = UCase(CheckDescription) CheckDrawnBy = UCase(CheckDrawnBy) CheckDesignedBy = UCase(CheckDesignedBy) CheckCheckedBy = UCase(CheckCheckedBy) CheckRevision = UCase(CheckRevision) CheckFinish = UCase(CheckFinish)

***********************************************************************
Reply to
James Spisich

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.