Using the Write # method (remove quote marks from output)

tranchemontaigne

Registered User.
Local time
Yesterday, 21:38
Joined
Aug 12, 2008
Messages
203
When I use the Write # method to srite string data into a text output file, the output is nested between double quotes.

My problem is that I want to dynamically create a batch file that deletes temporary files MS Access has created (through custom VBA code) upon exit.

When I use this approach the batch file always fails because the DOS command is nested between double quotes.

strFileAndPath = CurrentProject.Path & "\ClearTempFiles.bat"

Open strFileAndPath For Output Access
Write As #1 strBatchInstruction = "DEL " & Chr(34) & CurrentProject.Path & "\~*.*" & Chr(34)
Write #1, strBatchInstruction
Close #1

Call Shell(strBatchInstruction)

SetAttr strFileAndPath, vbHidden

DoCmd.Quit

Any thoughts or suggestions on how to solve this problem would be appreciated
________
Uhwh Warehouse
 
Last edited:
try print instead of write

i think you get a CrLf at the end, but no quotes
 
The normal syntax for this method is

Dim ff as FreeFile

Code:
Open StrFilePath For Output As #ff
Print #ff, Your command line here
Close #ff
 
Got an example of your thoughts please.
 
What I was thinking was more of a log application where new entries could be added to an external log file.

I'm terriby rusty with my unix shell scripting, but I do recall scripts to open a log file, and append new values to either the start or end of an existing log (cat piped to sed?).

My thought was that I might be able to also use the VBA print method to convert internal error logging (via a table), to external logging (via a text file).
________
Ford Interceptor
 
Last edited:
i think you can open for append, rather than open for output

Open StrFilePath For Append as #channo
 
Gemma is corect you can us For Append to add lins to an existing file.
 

Users who are viewing this thread

Back
Top Bottom