i have an external rule opening drawings for all unsuppressed parts and assemblies. The code below automates the check-in process. I enabled Automatic Log In and Suppressed "Check-in" dialog and the check-in was smooth for instances where adding in a file were not required. My one snag is that I need to add comments. I now have taken out the dialog box Suppression and it has sped up checking in files, but I was wondering if there was a was to pass along a comment from a Message Input box. The comment would be the same for any parts which changed, so I could suppress the "Check-in" dialog box and still get a comment applied to that compontent.
ForEachodocAsInventor.DocumentInThisApplication.Documents
DimappAsInventor.Application=ThisApplication
DiminvdocAsInventor.Document=app.ActiveDocument
DimopathandnameAsString=invdoc.FullFilename
DimoextensionAsString=Right(opathandname,3)
DimposnAsInteger=0
posn=InStrRev(opathandname, ".")
Ifposn<>0Then
Ifoextension="dwg"Then
ThisApplication.ActiveDocument.Save
ThisApplication.CommandManager.ControlDefinitions.Item("VaultCheckinTop").Execute
'Close drawing file(s)
invdoc.Close(False)
'Clear out Addin variable string(s)
onamenoextension=Nothing
EndIf
EndIf
'Clear out application variable String(s)
opathandname=Nothing
posn=Nothing
oextension=Nothing
Next
Thanks in advance,
Solved! Go to Solution.
Solved by jdkriek. Go to Solution.
First you need to have the command wait for you if you hope to fill in the comments.
ControlDefinitions.Item("VaultCheckinTop").Execute2(True)
I've not had any luck actually filling in the comments though. Decided that we didn't need them after all, especially since it was being followed by an automatic state change to Release which was pretty much self-explanatory.
I've been able to fill in the comments by "cheating" a little bit.
Dim Comment as String
Comment = "This is the text that will show up in the comments box."
Set ctrdef = ThisApplication.CommandManager.ControlDefinitions.Item("VaultCheckInTop")
ctrdef.Execute2 False
SendKeys Comment & "{TAB}~"
The last line will "type" the Comment string into the comments field for the check in, and the {TAB}~ will jump over to the OK button and press OK, thereby initiating the check in.
Note that the Execute2 boolean is False. My understanding is that this allows VBA code to be executed even when the check in dialog box is open. If you just use Execute (or Execute2 true I think), the "typing" will only happen after the dialog box is closed (which won't fill in the comments).
Hope this helps!