Well well well... It seems that I have finally figured out this mysterious problem. I have been dreading coming back to this because of work being super busy, and the notion that it was going to be a real pain in the neck to track down, but after trying something out of frustration we all arrive at what I hope will be the solution for everyone.
So far I have tested it on both NL-Laurens' file (Found as an attachment in this thread), as well as the file found here, with successful results (the exception being that you'll have to remove the non-existing external rule for the file found using the above link if you want to also test it and succeed)!
Alright. So. For those that want the short and sweet answer I will post the snippet of original code (provided by robert.f), with the fix, and those who wanna know how I found it (for whatever reason) can stay. The modified code of robert's will be posted as an attachment!
This is the original code snippet that would handle the iPropertySet creation (for the iLogicEvent), which would not get set on certain problem files...
Original :
On Error Resume Next
Set customIPropSet = cDocument.PropertySets.Item("iLogicEventsRules")
If customIPropSet.InternalName <> "{2C540830-0723-455E-A8E2-891722EB4C3E}" Then
Call customIPropSet.Delete
Set customIPropSet = cDocument. _
PropertySets.Add("iLogicEventsRules", _
"{2C540830-0723-455E-A8E2-891722EB4C3E}")
End If
If customIPropSet Is Nothing Then
Set customIPropSet = cDocument.PropertySets.Add("iLogicEventsRules", _
"{2C540830-0723-455E-A8E2-891722EB4C3E}")
End If
If customIPropSet Is Nothing Then
MsgBox "Unable to create the Event Triggers property for this file!", _
, "Event Triggers Not Set"
Exit Sub
End If
Modified (Note - I totally didn't format this code, so if you paste it, you'll need to fix the ends) :
On Error Resume Next
Set customIPropSet = cDocument.PropertySets.Item("iLogicEventsRules")
If customIPropSet Is Nothing Then
Set customIPropSet = cDocument.PropertySets.Item("_iLogicEventsRules")
End If
If customIPropSet.InternalName <> "{2C540830-0723-455E-A8E2-891722EB4C3E}" Then
Call customIPropSet.Delete
Set customIPropSet = cDocument.PropertySets.Add("iLogicEventsRules", "{2C540830-0723-455E-A8E2-891722EB4C3E}")
End If
If customIPropSet Is Nothing Then
Set customIPropSet = cDocument.PropertySets.Add("iLogicEventsRules", "{2C540830-0723-455E-A8E2-891722EB4C3E}")
End If
If customIPropSet Is Nothing Then
MsgBox "Unable to create the Event Triggers property for this file!", , "Event Triggers Not Set"
Exit Sub
End If
What got added?
This line :
Set customIPropSet = cDocument.PropertySets.Item("_iLogicEventsRules")
For whatever reason, there is a hidden set of PropertySet for the iProperties that control event triggers. This is why it was impossible to create a new set using the necessary Internal Name ID! Technically it was already in use, and couldn't replicate! By checking for the hidden PropertySet in addition to the typically visible one, we are able to make the correct decision before attempting to create a new PropertySet.
-----------------------------
How I found it, and possibly a better way to move forward
-----------------------------
The below is just about the junk I did to figure this out, and will not be of much importance to most people. It's really just if you happen to also be in the position of wanting to know more about this topic, are interested in iProperties, or have a compulsive need to read absolutely everything that is in this post. If the above answered your question and you're alright with that, then simply download the modified code below and get to work on making awesome stuff!
---------
After numerous attempts to create a new iLogicEventsRules PropertySet which all failed, a few frustrated attempts to delete every PropertSet (out of spite mostly), and the creation of a non-correct Internally Named iLogicEventsRules PropertySet, I tried something silly.
Option Explicit
Public Sub ReadProperty()
Dim doc As Document
Set doc = ThisApplication.ActiveDocument
Dim customPropSets As PropertySets
Set customPropSets = doc.PropertySets
Dim customPropSet As PropertySet
Set customPropSet = customPropSets.Item("{2C540830-0723-455E-A8E2-891722EB4C3E}")
End Sub
For some reason it never occurred to me to call the PropertySet by its Internal Name rather than using the typical Display Name string, despite that it's clearly listed in the API reference guide.
From there, once I could see that object was no longer Nothing, I used the following to call it up again :
Set customPropSet = customPropSets.Item("_iLogicEventsRules")
Of course this leads to some other questions that perhaps someone more experienced can come in here and answer later... What sort of iProperties are hidden? Was the underscore used to denote iProperties back in the day, or is it way of marking up special iProperties that didn't exist before the file was migrated to a new release? Is it something that perhaps the Apprentice Server interacts with?
Someone smarter than me should answer that.
Needless to say, I'll have to make some more time in the near future and update the iLogic Injector so that it can be used by, hopefully, by more people!
Thanks for sticking around, and remember that if you still have any more questions, or if this doesn't seem to work for you, post post post!
If my solution worked or helped you out, please don't forget to hit the kudos button 🙂iLogicCode Injector:
goo.gl/uTT1IB