Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Press Ctrl+M
Change the options
Requested module Security - System Access
Current Local Security - System Access
Hi,
exit sub
Where you open it? Why you used in if condition?
If the directory or file does not exist then the code should create it.
Did that already. no luck..
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.