ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Plain .TXT file to Word .DOC file via Excel VBA - Possible? (https://www.excelbanter.com/excel-programming/420770-plain-txt-file-word-doc-file-via-excel-vba-possible.html)

Charlotte E.[_2_]

Plain .TXT file to Word .DOC file via Excel VBA - Possible?
 
Well, the subject says it all :-)

Plain .TXT file to Word .DOC file via Excel VBA - Possible?

If it's possible, could someone help me with the code?


TIA,

CE



joel

Plain .TXT file to Word .DOC file via Excel VBA - Possible?
 
This code will work. I'm using word to do the conversion, but running the
macro in Excel. Does that meet the requirements?

FName = "c:\temp\abc.txt"
WordFName = "c:\temp\abc.doc"

Set Wordobj = CreateObject("Word.Application")
Wordobj.Visible = True

Wordobj.Documents.Open Filename:=FName, _
ConfirmConversions:=False
Wordobj.activedocument.SaveAs Filename:=WordFName, _
FileFormat:=wdFormatDocument

Wordobj.Quit

"Charlotte E." wrote:

Well, the subject says it all :-)

Plain .TXT file to Word .DOC file via Excel VBA - Possible?

If it's possible, could someone help me with the code?


TIA,

CE




Charlotte E.[_2_]

Plain .TXT file to Word .DOC file via Excel VBA - Possible?
 
Thanks, Joel :-)

With a little modifications I got it to work, just as I wanted :-)

CE


Joel wrote:
This code will work. I'm using word to do the conversion, but
running the macro in Excel. Does that meet the requirements?

FName = "c:\temp\abc.txt"
WordFName = "c:\temp\abc.doc"

Set Wordobj = CreateObject("Word.Application")
Wordobj.Visible = True

Wordobj.Documents.Open Filename:=FName, _
ConfirmConversions:=False
Wordobj.activedocument.SaveAs Filename:=WordFName, _
FileFormat:=wdFormatDocument

Wordobj.Quit

"Charlotte E." wrote:

Well, the subject says it all :-)

Plain .TXT file to Word .DOC file via Excel VBA - Possible?

If it's possible, could someone help me with the code?


TIA,

CE





All times are GMT +1. The time now is 12:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com