Click to See Complete Forum and Search --> : Wants to save xml file in VB


kya_karey2002
06-10-2005, 03:19 AM
Hi,
I have problem saving in new xml file.

I have one xml file called "test.xml"
I wrote my program in Visual Basic
I am opening the file and writing some content in that now i want to save again this file as "test1.xml"

My problem is the file is saving in word format not in .xml format

can anybody help me for this.

My code is like below:

Set appword = CreateObject("Word.Application")
appword.Visible = True
xtemplatePath = "D:\Test.xml"
Set docWord = appword.Documents.Open(xtemplatePath)
Set docWord = appword.Documents.Add()
Set rngCourant = docWord.Content

With rngCourant
.InsertAfter "<?xml version = '1.0' encoding = 'ISO-8859-1'?>"
.InsertAfter vbNewLine
.InsertAfter "<TransportConfiguration xmlns = 'http://www.localhost.fr/transport' xmlns:xsi = 'http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation = 'http://www.localhost.fr/transport D:\transportConfigurationModel_OSY_R5_V1-6.xsd'>"
.InsertAfter vbNewLine
.GrammarChecked = False
.InsertAfter vbNewLine
.InsertAfter "<fileType>TEMPLATE</fileType>"
.InsertAfter vbNewLine
.InsertAfter vbNewLine
.InsertAfter "</TransportConfiguration>"
.InsertAfter vbNewLine
End With

xsaveDoc = "D:\Test1.xml"
docWord.SaveAs xsaveDoc

docWord.Application.Quit
Set docWord = Nothing


If i open this file in tool like "XML SPy" it couldnt able to read the content of the file. AS per my view this file is saved by taking extension word not .xml

Can anybody help me with this