VBA Xml

somesoldiers

Board Regular
Joined
Feb 23, 2008
Messages
199
Hi All

I have the below which is working fine
VBA Code:
Print #1, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "utf-8" & Chr(34) & "?>"

which produces
VBA Code:
<?xml version="1.0" encoding="UTF-8"?>

on the output xml fine. I need to change this to include standalone so
VBA Code:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>

can someone help me please as am getting bogged down on Chr(34) etc?
thanks
Noel
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try it this way...

VBA Code:
Print #1, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "utf-8" & Chr(34) & " standalone=" & Chr(34) & "True" & Chr(34) & "?>"
 
Upvote 0
Hi Rick, thanks for your response

when I run the code it is not producing anything. To be clear on what I did

I commented out the original (which does produce the xml) & pasted your code as below

VBA Code:
  'Print #1, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "utf-8" & Chr(34) & "?>"
   Print #1, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "utf-8" & Chr(34) & " standalone=" & Chr(34) & "True" & Chr(34) & "?>"
 
Upvote 0
If the code line you commented out works, the I would think what I posted has to work as well. Paste this into the Immediate Window in the VBA editor, then hit the Enter Key. It should print out what you said you wanted back in Message #1. All I did is remove the "print to file" command and replace it with VBA's Immediate Window print command.

VBA Code:
? "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "utf-8" & Chr(34) & " standalone=" & Chr(34) & "True" & Chr(34) & "?>"
 
Upvote 0
The easiest method is to double the internal double-quotes, like this:
VBA Code:
Print #1, "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""true""?>"
 
Upvote 0
cool that worked, thanks CephasOz

For anyone else searching for the same issue, using "true" produced nothing, "yes" worked with the below and the "yes" then produces the True on the xml file

<?xml version="1.0" encoding="UTF-8" standalone="true"?>

VBA Code:
Print #1, "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>"
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,947
Members
448,534
Latest member
benefuexx

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