![]() |
|
#8
|
||||
|
||||
|
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
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
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 |
| Tags |
| save |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
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 |
Word Macro: Save file as text with current file name
|
jabberwocky12 | Word VBA | 2 | 10-22-2010 12:23 PM |