Convert .docx to .doc

Posted by Dotnetrajanikanth under ASP.NET on 7/19/2012 | Points: 10 | Views : 2483 | Status : [Member] | Replies : 6
Hi,

I want links / code to convert a .docx file to .doc file using asp.net.

____________
www.flickr.com/photos/psdesigner/



Responses

Posted by: Ranjeet_8 on: 7/19/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
  string oldfilename = "Your File Name";

FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + oldfilename);
if (TheFile.Exists)
{
string fullname= TheFile.FullName.ToString();
File.Move(MapPath(".") + "\\" + oldfilename, MapPath(".") + "\\" + fullname + ".doc");
}


Dotnetrajanikanth, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Megan00 on: 7/19/2012 [Member] Starter | Points: 25

Up
0
Down
Try using below code:
            Document mydoc = new Document();

mydoc.LoadFromFile(@"..\test.docx");
mydoc.SaveToFile("result.doc", FileFormat.Doc);

This need a word component:http://www.e-iceblue.com/Introduce/word-for-net-introduce.html to realize it.

Never give up! Smile to the world!
http://excelcsharp.blog.com/

Dotnetrajanikanth, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rchennaiah on: 7/20/2012 [Member] Starter | Points: 25

Up
0
Down
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Word;

Microsoft.Office.Interop.Word.Application _Word = new Microsoft.Office.Interop.Word.Application();
object missing = System.Reflection.Missing.Value;


object oOpenName = @"F:\ChennaiahBackup\EHRDocs\CEHRUpdateService Installation Instructions.docx";

object oSaveName = @"F:\CEHRUpdateService.doc";

object oHTMLFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument97;

Document doc =_Word.Documents.Open(ref oOpenName, ref missing, ref missing,

ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,

ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);


doc.SaveAs(ref oSaveName, ref oHTMLFormat, ref missing, ref missing, ref missing,

ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,

ref missing, ref missing, ref missing, ref missing, ref missing);

MessageBox.Show("Success");

Dotnetrajanikanth, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dotnetrajanikanth on: 7/20/2012 [Member] Starter | Points: 25

Up
0
Down
Ranjeet_8,Megan00

Thanks for your code... But it is not working , Megan00 if you can get that plugin for free please let me know.

Rchennaiah,

Let me try your code

____________
www.flickr.com/photos/psdesigner/

Dotnetrajanikanth, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dotnetrajanikanth on: 7/20/2012 [Member] Starter | Points: 25

Up
0
Down
Rchennaiah,

Tried your code.. But not working.. I think your code is just equal to renaming it to .doc

____________
www.flickr.com/photos/psdesigner/

Dotnetrajanikanth, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Megan00 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
using the above code, you need to download that word component, it is not free, only using it, you can realize your docx to doc or doc to docx, below article can help you:
http://everlasting129.weebly.com/8/post/2012/07/two-lines-code-convert-docx-to-doc-with-cvbnet.html


Never give up! Smile to the world!
http://excelcsharp.blog.com/

Dotnetrajanikanth, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response