PDA

View Full Version : Suppress word warning messages



mathzhang
11-22-2010, 10:53 AM
Hi Guys,

I simply want to save a .rtf file into .txt format. Here is the code:


Dim file_path As String
file_path = "d:\working\vba\filename.rtf"

Dim wdApp As Word.Application
Set wdApp = GetObject(, "Word.Application")

Dim wdDoc As Word.Document
Set wdDoc = wdApp.Documents.Open(file_path)

wdDoc.Activate
wdDoc.SaveAs Filename:="d:\working\vba\filename.txt", _
FileFormat:=wdFormatText
wdDoc.Close

However, I always got the following warning message:

" The document may contain text content that will be lost upon conversion to the chosed encoding..... Do you want to continue saving the document?"

The program can only go on if I choose "YES". Any idea how to suppress this warning message? Thanks very much!

fumei
11-22-2010, 11:33 AM
I am not sure you can.

BTW: you do not need

wdDoc.Activate

It already IS Active.

mathzhang
11-22-2010, 11:49 AM
I am not sure you can.

BTW: you do not need

wdDoc.Activate

It already IS Active.

Thanks for the reply. The problem is that I have thousands of .rtf files that I want to save into .txt. The warning message creates a big trouble.

macropod
11-22-2010, 03:41 PM
Hi mathzhang,

I'm not sure if this will work, but you might try:
Application.DisplayAlerts = False
(Reset it to True afterwards, though).

shekhu
01-04-2011, 11:07 PM
mathzhang,

The problem is that I have thousands of .rtf files that I want to save into .txt. The warning message creates a big trouble.

Sorry for a late reply, why dont you use a small freeware software "Lupas Rename 2000". This is just a suggestion for you, try this out.