Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Announcing the newest addition to the Qlik Community, Qlik Gallery! Learn More
Highlighted
rustyfishbones
Honored Contributor II

Macro to Move File

Hi All,

I have taken a Macro that deletes a file and tried to modify it to Move a file, here is what I have, I get no errors, it does not move the file, it just takes me back into the Edit Module screen, any ideas?

FUNCTION MoveFile(mFile)

SET oFile = CREATEOBJECT("Scripting.FileSystemObject")

currentStatus = oFile.FileExists(mFile)

IF currentStatus = TRUE THEN

oFile.MoveFile(mFile)

END IF

SET oFile = Nothing

END FUNCTION

SUB MoveFiles

SET doc = ActiveDocument

    SET mySelections = doc.fields("Full Path").GetSelectedValues

   

    FOR i = 0 to mySelections.Count - 1

  

    MoveFile mySelections.Item(i).text, "C:\Users\alan\Desktop\"

     

       

    NEXT

  

END SUB

Tags (3)
1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Macro to Move File

I would rather try something like this:

SUB MoveFile(source, destination)

SET oFile = CREATEOBJECT("Scripting.FileSystemObject")

currentStatus = oFile.FileExists(source)

IF currentStatus = TRUE THEN

     oFile.MoveFile(source, destination)

END IF

SET oFile = Nothing

END SUB

SUB MoveFiles

SET doc = ActiveDocument

SET mySelections = doc.fields("Full Path").GetSelectedValues

    FOR i = 0 to mySelections.Count - 1

       file = mySelections.Item(i).text

       call MoveFile(file, "C:\Users\alan\Desktop\")

       doc.GetApplication.Sleep 1000

    NEXT

END SUB

- Marcus

2 Replies
MVP & Luminary
MVP & Luminary

Re: Macro to Move File

I would rather try something like this:

SUB MoveFile(source, destination)

SET oFile = CREATEOBJECT("Scripting.FileSystemObject")

currentStatus = oFile.FileExists(source)

IF currentStatus = TRUE THEN

     oFile.MoveFile(source, destination)

END IF

SET oFile = Nothing

END SUB

SUB MoveFiles

SET doc = ActiveDocument

SET mySelections = doc.fields("Full Path").GetSelectedValues

    FOR i = 0 to mySelections.Count - 1

       file = mySelections.Item(i).text

       call MoveFile(file, "C:\Users\alan\Desktop\")

       doc.GetApplication.Sleep 1000

    NEXT

END SUB

- Marcus

rustyfishbones
Honored Contributor II

Re: Macro to Move File

Hi Marcus,

That worked perfectly, although I had to remove parentheses from

oFile.MoveFile(source, destination)