.NET Convert .RTF to .DOTX

How to convert .RTF to DOTX in .net
LVL 15
Ess KayEntrapenuerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
A .dotx is a template file so the conversion is the same as for a .docx just change the extension
Ess KayEntrapenuerAuthor Commented:
not working

Im doing this:
It makes DOCX only, i need dotx
DIM dotXLoc as string = "c:/temp/word.docx"
DIM rtfLoc as string = "c:/test/test.rtf"

Dim wordApp As Object = New Microsoft.Office.Interop.Word.Application()
Dim currentDoc As Microsoft.Office.Interop.Word.Document = wordApp.Documents.Open(rtfLoc)
currentDoc.SaveAs(dotXLoc, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocumentDefault)
currentDoc.Close()
wordApp.Quit()

Open in new window



If i change to DOTX extension  
dotXLoc  = "c:/temp/word.DOTX"
, it still saves in docx format, so basically, to open the file, i have to manually change the ext to docx in windows explorer
MacroShadowCommented:
DIM dotXLoc as string = "c:/temp/word.dotx"
DIM rtfLoc as string = "c:/test/test.rtf"

Dim wordApp As Object = New Microsoft.Office.Interop.Word.Application()
Dim currentDoc As Microsoft.Office.Interop.Word.Document = wordApp.Documents.Open(rtfLoc)
currentDoc.SaveAs(dotXLoc, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatTemplate)
currentDoc.Close()
wordApp.Quit()

Open in new window


Note the WdSaveFormat

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ess KayEntrapenuerAuthor Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.