Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Does anyone know if we can use relative paths for theobject export. Right now I am using obj.Export
"Z:\Documents\CheggSVN\EDW\reporting\trunk\qlikview\"&object_id&".csv",","
But anything I change it to like obj.Export ""&object_id&".csv","," or obj.Export "../qlikview/"&object_id&".csv","," all give me an error cannot open file for writing. Even if it is in the exact location as the hard coded path. I just want to make this relative so we can deploy it to different environemnts and know the structure will be there. This full absolute path is brittle.
I usually set up some global variables along the lines of the following. The key is to set the current working directory using .MyWorkingDirectory, then navigate up the filepath using the InStrRev function. Test this sample macro.
sub CurrentDir
Dim docProp
set docProp = ActiveDocument.GetProperties
Dim tmpFile 'used to create relative filepaths
tmpFile = docProp.MyWorkingDirectory
msgbox tmpFile
Dim vSpl 'location of final backslash char
vSpl = InStrRev(tmpFile,"\")
msgbox vSpl
tmpFile = Left(tmpFile,vSpl) & "QVOutputData\example.txt" 'file will be written one folder up, then two down
msgbox tmpFile
end sub
flipside
have you tried with backslashes?
Yeah and with no slashes just trying to drop it in the root dir but same error. I have to hard code the full path from the drive letter forward.
I usually set up some global variables along the lines of the following. The key is to set the current working directory using .MyWorkingDirectory, then navigate up the filepath using the InStrRev function. Test this sample macro.
sub CurrentDir
Dim docProp
set docProp = ActiveDocument.GetProperties
Dim tmpFile 'used to create relative filepaths
tmpFile = docProp.MyWorkingDirectory
msgbox tmpFile
Dim vSpl 'location of final backslash char
vSpl = InStrRev(tmpFile,"\")
msgbox vSpl
tmpFile = Left(tmpFile,vSpl) & "QVOutputData\example.txt" 'file will be written one folder up, then two down
msgbox tmpFile
end sub
flipside
wow, that was much harder than it ever needed to be for a relative path . But it worked.
Thanks