Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Writting a table to a text file

I need to write an input table to a text file.  I have a button on a document that has a vbscript that should do this.  However when I click on the button I get an access denied error. I am logged in as myself and am an admin on the machine.

Here is my code:

Activedocument.ClearAll

vDirectory ="..\Config"

' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
vFile = "..\Config\Years.txt"

'Either use or create a directory pending on whether it exists
On Error Resume Next
If objFSO.FolderExists(vDirectory) Then
     Set objFolder = objFSO.GetFolder(vDirectory)
Else
     Set objFolder = objFSO.CreateFolder(vDirectory)
End If

set obj = ActiveDocument.GetSheetObject("Years")

' Export Current object  to file
obj.Export vFile,","
If Err.Number <> 0 Then
      msgbox( "Error Saving Years -- Description: " &  Err.Description)
      exit sub
    Err.Clear
End If
On Error Goto 0
set obj = Nothing

Any assistance would be much appriciated.

5 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Press Ctrl+M

Change the options

Requested module Security - System Access

Current Local Security - System Access

MayilVahanan

Hi,

     exit sub

     Where you open it? Why you used in if condition?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

If the directory or file does not exist then the code should create it.

Not applicable
Author

Did that already.  no luck..

Not applicable
Author

hmm..  seems to be related to the relative path I'm using.  If I change the relative paths to full path name.  It seems to work.