Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Goodevening, experts!
I have simple qvw with working macro, which deletes qvd file, location of which is defined in vPath variable.
I am working now with a solution to delete all files, which have necessary file name mask and only those files, which contain available company name in file name.
So expected result - to delete Data_A_file.qvd, Data_B_file.qvd => as D company isn't included into data model.
Would be grateful for each advice!
Raw data and qvw is in the attachment.
Thanks.
Your delete Sub could look like this:
Sub delete
Set val=ActiveDocument.Fields("Company").GetPossibleValues
For i=0 to val.Count-1
File = "Data_" & val.Item(i).Text & "_file.qvd"
DeleteFile(File)
Next
End Sub
Your delete Sub could look like this:
Sub delete
Set val=ActiveDocument.Fields("Company").GetPossibleValues
For i=0 to val.Count-1
File = "Data_" & val.Item(i).Text & "_file.qvd"
DeleteFile(File)
Next
End Sub
Thanks.
Also it would be great to have possibility to define File = "Data_" & val.Item(i).Text & "_file.qvd" using file name mask.
So now it uses hard coded position of company id in the name.
Is it possible to use like * symbol in the file name?
Then you should try this:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery(" Select * from CIM_DataFile where FileName Like '%~% ' ")
For Each objFile in colFiles
MsgBox objFile.Name
Next
This snippet is from the Microsoft documentation:
https://msdn.microsoft.com/en-us/library/aa387236(v=vs.85).aspx