I have an epdm template for creating Corrective Action Reports in epdm. It was set to automatically check in the excel file after the form is filled out. However, whenever the form is filled out and it's automatically checked in, the values are filled out on the data card, but not in the file. If anyone except the file author checks it out, all the data gets cleared out and the form appears blank. This only happens about 20% of the time, but it's enough to be a serious issue.
After extensive research and working with our VAR, the problem was determined to be the template option "Check in the file using the following comment:". Since unchecking that, the problem has been resolved, but this has made it so the user has to check the file in themself after creation. I am trying to reduce the burden on the user by having the file automatically check in.
I created an add-in that opens a file using the "post-add" hook and can get it to trigger when an excel file is created in that specific folder. The add-in opens the newly created file, refreshes all sheets, saves, closes, and checks the file in. It works great when a file is created manually. However, when a file is created using the template, neither the pre-add or post-add hooks get called.
Does anyone have any experience with this? Is there a way around it?
Thanks,
Tara
Edit: Added Code (Below)
SolidworksApi macrosPublic Sub OnCmd(ByRef poCmd As EdmCmd, ByRef ppoData As System.Array) Implements IEdmAddIn5.OnCmd
Try
Dim vault As IEdmVault5 = poCmd.mpoVault
Dim CARfolder As IEdmFolder5 = vault.GetObject(EdmObjectType.EdmObject_Folder, ppoData(0).mlObjectID1)
If CARfolder.Name = "Corrective Action Reports" Then
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
Dim excelBook As Workbook = xlApp.Workbooks.Open(ppoData(0).mbsStrData1)
excelBook.RefreshAll()
excelBook.Save()
excelBook.Close()
Dim CARfile As IEdmFile5 = vault.GetObject(EdmObjectType.EdmObject_File, ppoData(0).mlObjectID2)
CARfile.UndoLockFile(0)
End If
Catch ex As System.Runtime.InteropServices.COMException
MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub