Posted 18 January 2010 - 08:42 PM
I hope someone is familiar with the VBA Extensibility reference. That's the thing that lets you write code that modifies forms, modules, and projects at design time. It's very useful and notoriously badly documented.
I have some procedures that literally work one day and don't work the next. I can't figure out why. As an example:
For each aVbc in MyDoc.VBProject.VBcomponents
If left(aVbc.name, 8) = "UserForm", then
ActiveDocument.VBProject.VBComponents.Remove(aVbc) ' <=== FAIL Object does not support this property or method.
' I also tried this instead:
aVbc.Remove ' <=== FAIL: Object does not support this property or method.
It used to work, honest. What could I have done that changed it?