Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-17-2021, 12:36 AM
macropod's Avatar
macropod macropod is offline sort custom document properties Windows 10 sort custom document properties Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your code could be greatly simplified. For example, to produce an alpha-sorted Custom Document Property list:
Code:
Sub Sort_Custom_Document_Properties()
Dim DocProp As DocumentProperty, CustPropArr() As String
ReDim Preserve CustPropArr(0): CustPropArr(0) = ""
' Add Custom Document Properties to Array
For Each DocProp In ActiveDocument.CustomDocumentProperties
  With DocProp
    If InStr(1, .Name, "contenttype", vbTextCompare) = 0 Then
      ReDim Preserve CustPropArr(UBound(CustPropArr) + 1)
      CustPropArr(UBound(CustPropArr)) = .Name & "|" & .Type & "|" & .Value
    End If
  End With
Next DocProp
WordBasic.SortArray CustPropArr
MsgBox Join(CustPropArr, vbCr)
End Sub
Note that the above code also explicitly captures the property type.

I'm not convinced there's much to be gained by reinserting them in the sorted order, though.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
sort custom document properties Phantom fields (custom document properties)- where do they come from - and how can they be stopped?! andiekit Word 13 03-18-2021 07:02 AM
sort custom document properties Adding Custom Document Properties NicoleJones Word VBA 3 03-10-2021 08:43 PM
sort custom document properties Create Custom Document Properties with Content Control kschmidt Word VBA 7 02-04-2019 03:09 PM
sort custom document properties Updating Document Properties without using advanced properties dialogue thedr9wningman Word VBA 3 01-20-2014 05:56 PM
sort custom document properties Add custom document properties into document NicBodkin Word 8 05-05-2011 09:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft