Dear All,
I have more than 100 notepad files (.txt). I need to convert all these notepad files to word files(.doc) at a time . I will be happy if I get any macro to solve my issue.
Dear All,
I have more than 100 notepad files (.txt). I need to convert all these notepad files to word files(.doc) at a time . I will be happy if I get any macro to solve my issue.
I have to ask a) why would you want to do that? and b) why would you want to do it in Excel?
Word can open .txt files and you can make MS Word the default assignment for .txt files
Trevor Shuttleworth - Retired Excel/VBA Consultant
I dream of a better world where chickens can cross the road without having their motives questioned
'Being unapologetic means never having to say you're sorry' John Cooper Clarke
Hi TMS , Thanks for reply
a) We have a server & every day this server generate more than 100 text file automatically . these file contains some networks related information. Now I am to upload these file to web portal but the web portal does not support .txt file . it support only documents file not .txt file. That’s way what I am currently doing , one by one open that notepad file & save as .doc
b) I thought there might be a solution of macro . maybe there have some DOS command that will be implemented inside the macro module to solve the task
Hi !
Nothing to do here as an Excel forum so try on the Word section …
Excel does not contain a feature for converting an Excel file into a Word file, and Word cannot directly open Excel files. However, an Excel table can be copied and pasted into Word and then saved as a Word document.
So, you'd need to open the .txt file in Excel, select the data and convert it into a Table. Then open a new Word document, copy the Table from Excel and Paste it into Word. Name, Save and Close the new Word document. And you'd need to make that into a loop to pick up all the .txt files.
You can read the whole text file into a string variable and then paste that into a Word document
Courtesy: http://codevba.com/office/read_text_...m#.XNrPvPZFzIUPlease Login or Register to view this content.
I guess that would miss out a couple of stages
Can't help thinking you'd be better off getting someone with Word VBA skills to do this for you. You should be able to use the same VBA code in Word.
Ok, this demonstrates the process. You'll need some code to get your list of files but there are lots of examples of using Dir, etc., to loop through files in a folder.
Please Login or Register to view this content.
I'm no expert and this is cobbled together from examples I've researched. It is tested and it does work. It's just missing the "front end" to process the .txt files in a folder.
This will be better for linking to a front end process:
Please Login or Register to view this content.
Hi TMS, Finally I got the solution for changing file format from .txt to .doc with the help of command prompt. here is the DOS command prompt.
Is it possible to run this small DOS command through Excel macro? If not possible then I will close the thread as one solution already got. Again thanks for trying to help me.Please Login or Register to view this content.
You will need a reference to MS Word … that will make the Compile Error go away.
Why would you want to run a single line DOS Command from Excel?
You might as well create a DOS Batch file and run that.
Thanks for the rep.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks