Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-20-2018, 09:15 AM
VBorNotVB VBorNotVB is offline Save as txt : How to detect if Unicode encoding is required? Mac OS X Save as txt : How to detect if Unicode encoding is required? Office 2016 for Mac
Novice
 
Join Date: Oct 2018
Location: Southern California
Posts: 25
VBorNotVB is on a distinguished road
Default

I believe the following function will solve your problem:

Code:
Function CanSaveDocAsTxt() As Boolean
    Dim i As Integer
    With ActiveDocument
        For i = 1 To .Characters.Count
            .Characters(i).Select
            'if AscW(.characters(i).Text) > 127 then exit function
            With Dialogs(wdDialogInsertSymbol)
                If .Font <> "(normal text)" Then Exit Function
            End With
        Next i
    End With
    CanSaveDocAsTxt = True
End Function
It goes through all characters in the active document and returns True if all characters in the document are part of (normal text) character set. Bear in mind that this character set has ANSI characters (character code points between 128 and 255). If you want to limit your text file to characters in ASCII range (0-127), then uncomment the commented statement above. This function does not check the document for shapes (images, etc.) - But I assume you know which documents do!

Last edited by macropod; 11-20-2018 at 01:55 PM. Reason: Added code tags to restore formatting
Reply With Quote
 

Tags
activedocument.saveas, encoding, txt



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro help - converting proprietary encoding to unicode, keep formatting kmawhood Word VBA 3 04-29-2016 04:06 PM
Save as txt : How to detect if Unicode encoding is required? Does 'Save as Unicode text' equal UTF-8 Chayes Excel 1 07-20-2012 03:07 AM
Save as txt : How to detect if Unicode encoding is required? Custom Dictionary & Unicode encoding? markus staubmann Word 3 03-28-2012 05:23 AM
Save as txt : How to detect if Unicode encoding is required? Save Word doc in unicode html (utf-8) rybrns Word 5 09-26-2011 02:18 PM
Save as txt : How to detect if Unicode encoding is required? Unicode Encoding Type Rose44 Excel 2 08-09-2009 09:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:59 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