PDA

View Full Version : Wordperfect to Word



stapuff
01-18-2010, 12:24 PM
I have what appears to be a billion Wordperfect files that have been given to me to convert so they can be open with Word.
Looking for a piece of code that I could navigate to a folder and change all .wpd to .doc. Any help would be greatly appreciated.

Kurt

fumei
01-18-2010, 02:26 PM
This is not going to work. Simply changing .wpd to .doc will NOT make them native Word files.

"so they can be open with Word." Word has a WordPerfect converter. It is not perfect by any means, but it is there. The point being is that it may be better to open them in Word, using the converter, then after, saving them as .doc.

You are going to have to look at each one carefully though. Some funny things can happen.

stapuff
01-18-2010, 03:02 PM
B.C. in the house!

I live about 30 minutes south of the border in Washington. I miss the whole area.....sorry about day dreamin'

Fumei - I appreciate your response back. I understand what you are saying. I created the following to do what I needed to do. It worked on a test folder I created with about 150 .wpd's in it. Took about 15 minutes to run.

Ran into a couple issues. I keep getting an "Do you want to update links blah, blah, blah" and I was trying to find out programmically to say "Yes" to all

The last issue is to find and replace a Phrase in the Header, Footer, and body of each of these.





Sub BatchChange()
Dim oDoc As Word.Document
Dim sPath As String
Dim sFileSpec As String
Dim sFile As String
Dim sFileList() As String
Dim i As Integer

' Get Folder
sPath = InputBox("Enter Word Doc Folder to Process", "Batch", "")

' Clean up
sPath = Trim(sPath)
If Right((sPath), 1) <> "\" Then sPath = sPath & "\"

' Add Wordperfect extention
sFileSpec = sPath & "*.wpd"

' Get All filenames in the Folder
sFile = Dir$(sFileSpec)

i = -1
Do Until sFile = ""
i = i + 1
ReDim Preserve sFileList(i) As String
sFileList(i) = sFile
sFile = Dir$
Loop

' Process each file
For i = 0 To UBound(sFileList)
Set oDoc = Word.Documents.Open(sPath & sFileList(i))

a = Len(sFileList(i)) - 3
b = Left(sFileList(i), a)

oDoc.SaveAs (sPath & b) & "doc"

Call oDoc.Close(True)
Kill (sPath & sFileList(i))
Next i

' Release dynamic array
Erase sFileList
End Sub

geekgirlau
01-18-2010, 05:24 PM
Untested, but this may switch off the alert messages:

application.DisplayAlerts=wdAlertsNone

fumei
01-19-2010, 11:29 AM
Oh, I was not saying you could not actually change the filenames. That is easy. What I was saying is that the contents may not be exactly what you think they may be, and could not be what they were when they were WP files.

I am not sure why you are making an array. Dir can do this by itself.Sub BatchChange()

Dim sPath As String
Dim sFile ' note data type is variant

' Get Folder
sPath = InputBox("Enter Word Doc Folder to Process", "Batch", "")
' Clean up
sPath = Trim(sPath)
If Right((sPath), 1) <> "\" Then sPath = sPath & "\"

' Get All filenames with .wpd in the Folder
sFile = Dir(sPath & "*.wpd")
Do While sFile <> ""
Documents.Open (sPath & sFile)
' do the SaveAs
ActiveDocument.SaveAs FileName:=sPath & _
Left(sFile, Len(sFile) - 4) & ".doc"
' close it
ActiveDocument.Close
' reset Dir
sFile = Dir()
Loop
End Sub

Notes:

1. notice the use of Left. sFile comes in as (for example) whatever.wpd. Therefore:
ActiveDocument.SaveAs FileName:=sPath & sFile & ".doc"
would result in whatever.wpd.doc

This isthe same as your use of left on your array items.

2. Because this is a SaveAs, the original files remain. In the folder it would:

whatever.wpd
yaddaYadda.wpd
whatever.doc
yaddaYadda.doc

In other words it is not a replace operation.

fumei
01-19-2010, 11:31 AM
Oh and...

"The last issue is to find and replace a Phrase in the Header, Footer, and body of each of these."

Chuckle.

Work out the logic and add it to the instructions.