By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

How do you drop the " from write#1?

P: 99
I have to load a string of text into a text file and then open the file in notepad. Here's my code:
Expand|Select|Wrap|Line Numbers
  1. newTxt = "C:\PathTo\newTxt.txt"
  2. Open newTxt For Output As #1
  3. Write #1, stringOfText_variable
  4. Close #1
FollowHyperlink newTxt

Everything works fine accept one thing. Quotes are appearing before and after the text and I can't seem to get rid of them. The finished text file always looks like this..

"
line one of text
line two of text
line three of text
"

It looks like these quotes are coming from the Write #1 statement. I've tried using MID function to lop them off before the Write #1 statement, but it didn't work... it lopped off the first and last character of text, but left the quotes.

Does anyone know how to get rid of those quotes?

thanks
Adam
Sep 4 '08 #1
Share this Question
Share on Google+
6 Replies


missinglinq
Expert 2.5K+
P: 3,532
Yes, Adam, it is coming from the Write statement. This is the normal behavior when you write to a text file from VBA, like the carriage return/linefeed you've already had problems with. Programs retrieving/using the data have to have some way to tell where one piece of data ends and the next piece begins. I'm not aware of anything you can do to deal with the problem before writing to the file. My guess would be that you'll have to deal with it on the other end, when you're retrieving the data.

Linq ;0)>
Sep 4 '08 #2

Megalog
Expert 100+
P: 378
Use Print #1 instead of Write #1 and you'll get no quotes.
Sep 4 '08 #3

missinglinq
Expert 2.5K+
P: 3,532
Good going,Megalog! I remembered that from the old Basic days (when Basic wasn't visible) and tried to amend my post, but the site is apparently experiencing access (access with no capital "A") problems again!

Linq ;0)>
Sep 4 '08 #4

P: 99
Thank you both. It worked like a charm.
Adam
Sep 4 '08 #5

Megalog
Expert 100+
P: 378
Glad to help. Little differences like that can be real frustrating sometimes.
Sep 4 '08 #6

NeoPa
Expert Mod 15k+
P: 31,470
If you look up Print # in the Access Help system you'll find a bunch about that and related ways of direct input / output (See also).

As Linq says, this is pure Basic and not related to the applications at all (works across all office applications).

Welcome to Bytes Adam :)
Sep 5 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.