AnsweredAssumed Answered

Trouble with CopyFile method

Question asked by David Bush on Dec 13, 2012
Latest reply on Dec 18, 2012 by Greg Rupp

I am relatively new to programming add-in's for EPDM and need some help tracking down this error. I am writing the API in Visual Basic 2008 Express and my vault version is 2012 sp02.


This add-in is supposed to copy a document from a folder and add the copy one level up. The name of the new file is going to be populated by a serial number, but I am using a placeholder "ECONUMBER" until I can get the CopyFile command to work.


When I run the add-in, the error I am getting is "Object reference not set to an instance of an object." I tracked the error down to the CopyFile command, but cannot get much further. Here is the section of code which I copied almost exactly from the Programmer's Reference Guide. If my issue isn't obvious from this section of the code I can post the whole thing. Thanks for your help!



                        Dim srcFolder As IEdmFolder5    'source folder variable

                        Dim file As IEdmFile5     'source file variable

                        Dim destFolder As IEdmFolder5    'destination folder variable

                        Dim fileID As String    'variable to store new file ID


                        srcFolder = ivault.GetFolderFromPath("C:\VAULT\00 - Engineering Change Orders\Requests")

                        file = ivault.GetFileFromPath("C:\VAULT\00 - Engineering Change Orders\Requests" & iFileName, srcFolder)    'populate source file variable

                        destFolder = ivault.GetFolderFromPath("C:\VAULT\00 - Engineering Change Orders")    'populate destination file variable


                        MsgBox("Variables Assigned", MsgBoxStyle.OkOnly) 'for debugging; this MsgBox displays before the error occurs


                        fileID = destFolder.CopyFile(file.ID, srcFolder.ID, 0, "ECONUMBER") 'copy file and store ID in fileID variable


                        MsgBox("Copy File Was Successful" & vbLf & _

                              "Source Filename: " & iFileName & vbLf & _

                             "New File ID: " & fileID & vbLf, MsgBoxStyle.OkOnly)