Consulting

Results 1 to 6 of 6

Thread: Wordperfect to Word

  1. #1

    Wordperfect to Word

    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

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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.

  3. #3
    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

  4. #4
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Untested, but this may switch off the alert messages:

    [vba]application.DisplayAlerts=wdAlertsNone[/vba]

  5. #5
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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.[vba]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
    [/vba]
    Notes:

    1. notice the use of Left. sFile comes in as (for example) whatever.wpd. Therefore:[vba]
    ActiveDocument.SaveAs FileName:=sPath & sFile & ".doc"
    [/vba]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.

  6. #6
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •