Spaces don't look like spaces?

spacely

Board Regular
Joined
Oct 26, 2007
Messages
241
Hello,

I am putting together a string, and using the print statement to output to a file.

I have an equation in the cell that I want to print out. The equation results in a string. That string has general characters, and spaces in it, and looks fine in excel. I use the following to print to file, using VBA:

theString = Cells(i, 6).Value
myFile = "myfile.json"
Open myFile For Output As #1
Print #1 , Replace(theString, vbLf, vbCrLf)
Close #1

All the characters in the resulting string-in-file are OK, except the spaces. And only when I load the file into Visual Studio Code, which is a good json file editor. In another text editor, the spaces look like spaces.

I cannot be sure I really have spaces where I should have spaces.

Can you help?
 

spacely

Board Regular
Joined
Oct 26, 2007
Messages
241
I solved it. I cut and pasted spaces from another App where apparently they don't past into excel as actual spaces. I had to hand-type in all the spaces in the excel cells.
 

DataBlake

Well-known Member
Joined
Jan 26, 2015
Messages
718
Office Version
2016
Platform
Windows
could you not replace the special character space with a regular space instead of hand typing everything?
vba syntax would be: replace(cell," " (special space), " ")
or vice versa.

might help you down the road if the problem occurs again
 

Forum statistics

Threads
1,086,227
Messages
5,388,571
Members
402,125
Latest member
mtwood83

Some videos you may like

This Week's Hot Topics

Top