Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2019, 03:56 AM
gmayor's Avatar
gmayor gmayor is offline How to Save a word as text file after applying font with UTF-8 Windows 10 How to Save a word as text file after applying font with UTF-8 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

That won't work. If you save as TXT, oDoc is then the text file that you have just saved.



To save the file as docx, you would either have to forget saving as txt and save as docx, or simply save oDoc instead of saving it as txt. e.g.

Code:
        'strName = Left(oDoc.FullName, InStrRev(oDoc.FullName, ".") - 1) & ".txt"
        'oDoc.Range.Font.Name = strFont
	oDoc.Save
        'oDoc.SaveAs2 FileName:=strName, FileFormat:=wdFormatUnicodeText
        oDoc.Close SaveChanges:=wdDoNotSaveChanges
If you want it as txt as well as docx then

Code:
        strName = Left(oDoc.FullName, InStrRev(oDoc.FullName, ".") - 1) & ".txt"
        oDoc.Range.Font.Name = strFont
	oDoc.Save
        oDoc.SaveAs2 FileName:=strName, FileFormat:=wdFormatUnicodeText
        oDoc.Close SaveChanges:=wdDoNotSaveChanges
Or SaveAs again e.g.

Code:
        strName = Left(oDoc.FullName, InStrRev(oDoc.FullName, ".") - 1) & ".txt"
        oDoc.Range.Font.Name = strFont
        oDoc.SaveAs2 FileName:=strName, FileFormat:=wdFormatUnicodeText
	strName = Left(oDoc.FullName, InStrRev(oDoc.FullName, ".") - 1) & ".docx"
	oDoc.SaveAs2 FileName:=strName, FileFormat:=wdFormatXMLDocument
        oDoc.Close SaveChanges:=wdDoNotSaveChanges
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Tags
save



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Save a word as text file after applying font with UTF-8 Word does not detect any text when applying style reference Stingerhawk Word 3 04-26-2019 01:33 AM
Save Document as Text File gerison Word VBA 5 11-27-2017 07:15 AM
Having Issues Applying a Macro Across Multiple Files. Changes Just Don't Seem To Save. Kajex Word VBA 2 09-08-2017 06:37 AM
Applying layout to existing slides without affecting font mgw130 PowerPoint 3 12-15-2012 04:38 AM
How to Save a word as text file after applying font with UTF-8 Word Macro: Save file as text with current file name jabberwocky12 Word VBA 2 10-22-2010 12:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft