Setting card variables in epdm add-in

I have an add-in (in c# .net) which creates dxf-files of each sheet of a drawing in a separate dxf file. I need to set some card variables for those dxf files in the same add-in. Using SetVar doesn't seem to work.

          IEdmFile5 fileObj = default(IEdmFile5);

          IEdmFolder5 retFolder = default(IEdmFolder5);

          fileObj = vault.GetFileFromPath(fileName, out retFolder);

          string filePath = Path.GetDirectoryName(fileName);

          IEdmEnumeratorVariable5 varE = (IEdmEnumeratorVariable5)fileObj.GetEnumeratorVariable(filePath);

          try

          {

                varE.SetVar(varName, config, ref varValue, false);

                IEdmEnumeratorVariable8 varE8 = (IEdmEnumeratorVariable8)varE;

                varE8.CloseFile(true);

           }

           catch (Exception e)

           {

                MessageBox.Show(e.Message);

           }

The error message is "The file isn't checked out by you, which is required by the operation.". However, even the checking out (which should not be required with SetVar, I think) won't help. Any ideas?

SolidworksApi macros