Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
On May 18th at 10AM EDT we will answer your QlikView questions live. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
rustyfishbones
Master II
Master II

Macro to Delete files outside Qlikview

Hi All,

I have a Qlikview Document that tracks files and folders.

I have buttons that can open the file or the Directory.

I am looking for a Macro that can delete a file I have selected

Thanks

Alan

1 Solution

Accepted Solutions
rustyfishbones
Master II
Master II
Author

This is what works

2013-10-09_1500.png

View solution in original post

8 Replies
Gysbert_Wassenaar

See this document:Useful Qlikview Macros


talk is cheap, supply exceeds demand
rustyfishbones
Master II
Master II
Author

Thanks G,

I found this and it works

FUNCTION DeleteFile(rFile)

set oFile = createObject("Scripting.FileSystemObject")

currentStatus = oFile.FileExists(rFile)

if currentStatus = true then

oFile.DeleteFile(rFile)

end if

set oFile = Nothing

END FUNCTION

SUB CallExample

  DeleteFile ("C:\MyFile.PDF")

END SUB

but I want it to delete a file I have selected from a Straight Table

like here

2013-10-09_1140.png

Gysbert_Wassenaar

I reckoned you already knew how to get the values from a field in a macro. Here's a bit from the api guide:

   set doc = ActiveDocument

   set mySelections = doc.fields("Field").GetSelectedValues

    

   for i = 0 to mySelections.Count - 1

      msbox mySelections.Item(i).text

   next

Perhaps activedocument.fields("Full Path").getselectedvalues.item(0).text is enough to get the value you want.


talk is cheap, supply exceeds demand
rustyfishbones
Master II
Master II
Author

Thanks G,

I think I may have it now

Thanks

rustyfishbones
Master II
Master II
Author

Actually I don't have it working.

Not sure what the issue is.

I have attached the qvw, would reallyappreciate if you could help get it working thanks G

rustyfishbones
Master II
Master II
Author

Just realised the QVW is no help to you!!

Gysbert_Wassenaar

Well, I can't actually delete the file, but if I select the file in the field Full Path first then I can use a msgbox to echo the file name. So that part works.


talk is cheap, supply exceeds demand
rustyfishbones
Master II
Master II
Author

This is what works

2013-10-09_1500.png

View solution in original post