AnsweredAssumed Answered

how to delete files on status change

Question asked by Bernhard Lang on Dec 15, 2017
Latest reply on Dec 16, 2017 by Bernhard Lang

Hi experts,


after I tried many codes from the web I finally have to ask if someone knows an answer here.


I want to delete .pdf, .dxf and .dwg files which have been created on realease of a sldprt.

When we now change the state to anything else e.g. in revision then all neutral file formats should be deleted from vault.

Option Explicit
Dim swApp As Object
Dim strFilePath as String
Dim oFSO as Object

Sub main()
Set swApp = Application.SldWorks

strFilePath = "<Path>\<Filename>.pdf"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Debug.Print strFilePath
If oFSO.FileExists("strFilePath") Then oFSO.DeleteFile "strFilePath"

End Sub

This will not work in a Task because I only have <path> and not the filename in here.

But if I manually set the complete filename nothing happens.

I also tried kill filename but it also doesn't work.

I got stuck in here and I have no idea how I should set up a deletion of those files which are obsolete since the status change,

When status changes to released/approved then the pdf will be generated new and old files will be overwritten with the PDF Task.


Could anyone give a suggestion.


Thank you in advance