Spaces don't look like spaces?

spacely

Board Regular
Joined
Oct 26, 2007
Messages
248
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?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top