Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6597073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:09:41+00:00 2026-05-25T18:09:41+00:00

Scenario : I have about 14000 word documents that need to be converted from

  • 0

Scenario: I have about 14000 word documents that need to be converted from “Microsoft Word 97 – 2003 Document” to “Microsoft Word Document”. In other words upgraded to 2010 format (.docx).

Question: Is there an easy way to do this using API’s or something?

Note: I’ve only been able to find a microsoft program that converts the documents to .docx but they still open in compatability mode. It would be nice if they could just be converted to the new format. Same functionality you get when you open an old document and it gives you the option to convert it.

Edit: Just found http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word._document.convert.aspx looking into how to use it.

EDIT2: This is my current function for converting the documents

Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click
    FolderBrowserDialog1.ShowDialog()
    Dim mainThread As Thread
    If Not String.IsNullOrEmpty(FolderBrowserDialog1.SelectedPath) Then
        lstFiles.Clear()

        DirSearch(FolderBrowserDialog1.SelectedPath)
        ThreadPool.SetMaxThreads(1, 1)
        lstFiles.RemoveAll(Function(y) y.Contains(".docx"))
        TextBox1.Text += "Conversion started at " & DateTime.Now().ToString & Environment.NewLine
        For Each x In lstFiles
            ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf ConvertDoc), x)
        Next

    End If
End Sub
Private Sub ConvertDoc(ByVal path As String)
    Dim word As New Microsoft.Office.Interop.Word.Application
    Dim doc As Microsoft.Office.Interop.Word.Document
    word.Visible = False

    Try
        Debug.Print(path)
        doc = word.Documents.Open(path, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)
        doc.Convert()

    Catch ex As Exception
        ''do nothing
    Finally
        doc.Close()
        word.Quit()
    End Try

End Sub`

It lets me select a path then find all doc files within the subfolders. That code isn’t important, all the files for conversion are in lstFiles. Only problem at the moment is that it takes a really long time to convert even just 10 documents. Should I be using one word application per document instead of reusing it? Any suggestions?

Also it opens word after about 2 or 3 conversions and starts flashing but keeps converting.

EDIT3: Tweaked to code above a little bit and it runs cleaner. Takes 1min10sec to convert 8 files though. Considering I have 14000 I need to convert this method will take a reasonably long time.

EDIT4: Changed the code up again. Uses a threadpool now. Seems to run a bit faster. Still need to run on a better computer to convert all the documents. Or do them slowly by folder. Can anyone think of any other way to optimize this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:09:42+00:00Added an answer on May 25, 2026 at 6:09 pm

    I ran your code locally, with just some minor edits for improved tracing and timing, and it “only” took 13.73 seconds to do 12 files. That would take care of your 14,000 in about 4 hours. I’m running Visual Studio 2010 on Windows 7 x64 with a dual core processor. Perhaps you can just use a faster computer?

    Here’s my full code, this is just a form with a single button, Button1, and a FolderBrowserDialog, FolderBrowserDialog1:

    Imports System.IO
    
    Public Class Form1
    
    Dim lstFiles As List(Of String) = New List(Of String)
    
    Private Sub DirSearch(path As String)
    
    
        Dim thingies = From file In Directory.GetFiles(path) Where file.EndsWith(".doc") Select file
    
        lstFiles.AddRange(thingies)
    
        For Each subdir As String In Directory.GetDirectories(path)
            DirSearch(subdir)
        Next
    End Sub
    
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        FolderBrowserDialog1.ShowDialog()
    
        If Not String.IsNullOrEmpty(FolderBrowserDialog1.SelectedPath) Then
            lstFiles.Clear()
    
            DirSearch(FolderBrowserDialog1.SelectedPath)
            Dim word As New Microsoft.Office.Interop.Word.Application
            Dim doc As Microsoft.Office.Interop.Word.Document
            lstFiles.RemoveAll(Function(y) y.Contains(".docx"))
            Dim startTime As DateTime = DateTime.Now
            Debug.Print("Timer started at " & DateTime.Now().ToString & Environment.NewLine)
            For Each x In lstFiles
                word.Visible = False
                Debug.Print(x + Environment.NewLine)
                doc = word.Documents.Open(x)
                doc.Convert()
                doc.Close()
            Next
            word.Quit()
            Dim endTime As DateTime = DateTime.Now
            Debug.Print("Took " & endTime.Subtract(startTime).TotalSeconds & " to process " & lstFiles.Count & " documents" & Environment.NewLine)
        End If
    
    End Sub
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario I have two wrappers around Microsoft Office, one for 2003 and one for
Scenario: I have an application that pulls data from a SQL database as well
Here is a particular scenario that I have been unclear about (in terms of
unihere's the scenario: I have a 1.8 million line text file that I need
Scenario I have a very heavy number-crunching process that pools large datasets from 3
Scenario I have a single base class and 2 (possibly 3) other classes that
I have a generic question about scope and encapsulation. Take two scenarios: Scenario 1:
Maybe it's not worth worrying about in this scenario, but lets say you have
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Scenario: You have an ASP.Net webpage that should display the next image in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.