Remove non ASCII characters from MS Word and save as text file using Excel VBA

iknowu99

Well-known Member
Joined
Dec 26, 2004
Messages
1,158
Office Version
  1. 2016
Hello Excellers,
I wrote a script to convert Word Doc to text and I need help removing characters that are non ascii. Everything saved to the text needs to be within 0-255 ascii and if there are characters that are not then they are removed.


Code:
Sub wrdDocTest()
Dim wd As Word.Application
Dim wDoc As Word.Document


Set wd = New Word.Application
Set wDoc = wd.Documents.Open(Range("A2").Value) 'MS Word data

'here need step to remove non 0-255 ASCII characters from wDoc object

Call wDoc.SaveAs(Replace(Range("A2"), ".docx", ".txt"), wdFormatDOSText, , , , , , , , , , , 

wDoc.Close
Set wDoc = Nothing
wd.Quit
Set wd = Nothing


End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,715
Messages
6,174,065
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top