Hoppa till huvudinnehåll

Hur batchkonverterar .doc-formatfiler till .docx i Word?

Om du antar att du har fått några Word-dokument i 97-2003-format, hur kan du konvertera alla dessa .doc-formatdokument till .docx-format på en gång? Den här artikeln visar två metoder för att lösa detta problem.

Batchkonvertera .doc-formatfiler till .docx med VBA-kod
Batchkonvertera .doc-formatfiler till .docx med Kutools för Word


Batchkonvertera .doc-formatfiler till .docx med VBA-kod

Detta avsnitt kommer att visa dig VBA-koden för att konvertera alla .doc-formatdokument i en viss mapp till .docx-dokument på en gång. Gör så här.

1. Samla alla dokument i .doc-format som du konverterar till .docx i en angiven mapp.

2. tryck på andra + F11 nyckel för att öppna Microsoft Visual Basic för applikationer fönster.

3. Klicka på i fönstret Insert > Modulerna. Kopiera sedan VBA-koden nedan till modulfönstret.

VBA-kod: Batchkonvertera alla .doc-formatdokument till .docx i en viss mapp

Sub ConvertDocToDocx()
'Updated by ExtendOffice 20181128
    Dim xDlg As FileDialog
    Dim xFolder As Variant
    Dim xFileName As String
    Application.ScreenUpdating = False
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show <> -1 Then Exit Sub
    xFolder = xDlg.SelectedItems(1) + "\"
    xFileName = Dir(xFolder & "*.doc", vbNormal)
    While xFileName <> ""
        Documents.Open FileName:=xFolder & xFileName, _
            ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
            PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
            WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
            wdOpenFormatAuto, XMLTransform:=""
        ActiveDocument.SaveAs xFolder & Replace(xFileName, "doc", "docx"), wdFormatDocumentDefault
        ActiveDocument.Close
        xFileName = Dir()
    Wend
    Application.ScreenUpdating = True
End Sub

4. tryck på F5 för att köra koden. I öppningen Bläddra välj den mapp som innehåller dokumenten .doc-format och klicka OK. Se skärmdump:

Sedan konverteras alla .doc-formatdokument till .docx-dokument omedelbart enligt nedanstående skärmdump.


Batchkonvertera .doc-formatfiler till .docx med Kutools för Word

Ett praktiskt verktyg rekommenderas i detta avsnitt. Med Doc / Docx nytta av Kutools för Wordkan du enkelt konvertera alla .doc-formatdokument i en mapp till .docx-dokument. Försök enligt följande.

Kutools för Word : Med mer än 100 praktiska Word-tillägg, gratis att prova utan begränsningar 60 dagar.

1. Samla alla .doc-format i en angiven mapp och klicka sedan på Kutools Plus > Doc / Docx. Se skärmdump:

2. I Dokumentformatkonverterare i dialogrutan måste du göra enligt följande:

2.1) Välj den mapp som innehåller .doc-formatdokument i Mapp för källfil sektion;
2.2) Välj Konvertera doc till docx från Format Konvertera rullgardinsmeny
2.3) Som standard är Destinationsväg samma som källa kryssrutan är markerad. Om du vill placera alla konverterade .docx-dokument i samma mapp, håll bara det här alternativet valt;
Om du vill separera .docx-dokumenten och källdokumenten, avmarkera kryssrutan Destinationsväg samma som källa och välj en ny mapp för att spara .docx-dokumenten i Spara till låda;
2.4) Klicka på Start knapp. Se skärmdump:

3. Sedan dyker en dialogruta upp för att berätta hur många dokument som har konverterats framgångsrikt, klicka på OK och stäng knappen Dokumentformatkonverterare fönster.

Nu konverteras alla .doc-format till .docx-filer. Se skärmdump:

Om du vill ha en gratis testversion av det här verktyget, gå till ladda ner programvaran gratis först och sedan tillämpa operationen enligt ovanstående steg.


Bästa kontorsproduktivitetsverktyg

Kutools för Outlook - Över 100 kraftfulla funktioner för att överladda din Outlook

🤖 AI Mail Assistant: Instant proffs-e-postmeddelanden med AI-magi – ett klick för geniala svar, perfekt ton, flerspråkig behärskning. Förvandla e-post utan ansträngning! ...

📧 Email Automation: Frånvaro (tillgänglig för POP och IMAP)  /  Schemalägg Skicka e-post  /  Auto CC/BCC enligt regler när du skickar e-post  /  Automatisk vidarebefordran (avancerade regler)   /  Lägg automatiskt till hälsning   /  Dela automatiskt e-postmeddelanden med flera mottagare i individuella meddelanden ...

📨 Email Management: Hämta enkelt e-postmeddelanden  /  Blockera bluff-e-postmeddelanden av ämnen och andra  /  Ta bort duplicerade e-postmeddelanden  /  Avancerad Sökning  /  Konsolidera mappar ...

📁 Bilagor ProBatch Spara  /  Batch lossa  /  Batchkomprimera  /  Automatisk sparning   /  Auto Lossa  /  Automatisk komprimering ...

🌟 Gränssnittsmagi: 😊 Fler vackra och coola emojis   /  Öka din Outlook-produktivitet med flikar  /  Minimera Outlook istället för att stänga ...

👍 Underverk med ett klick: Svara alla med inkommande bilagor  /   E-postmeddelanden mot nätfiske  /  🕘Visa avsändarens tidszon ...

👩🏼‍🤝‍👩🏻 Kontakter och kalender: Lägg till kontakter i grupp från valda e-postmeddelanden  /  Dela upp en kontaktgrupp till individuella grupper  /  Ta bort påminnelser om födelsedag ...

Över 100 funktioner Vänta på din utforskning! Klicka här för att upptäcka mer.

Läs mer       Gratis nedladdning      Inköp
 

 

Comments (14)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Dobrý den,
já bych potřeboval, ale VBA script který by fungoval včetně podsložek. Umíte někdo prosím upravit i tento skript? Děkuji.

ENG:
Good day,
I would need a VBA script that would work including subfolders. Can someone please edit this script as well? Thank you.
This comment was minimized by the moderator on the site
Hi Daniel Beneš,
To include subfolders, please try the following VBA code.
After adding the code, go to the Tools tab, click References, in the opening References - Project dialog box, check the Microsoft Scripting Runtime box, and then click the OK button to save the changes. See the following screenshot:
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/check-scripting_runtime.png
After that, press the F5 key to run the code.

Sub ConvertDocToDocx()
'Updated by ExtendOffice 20221124
  Dim xDlg As FileDialog
  Dim xFldPath As Variant
  Dim xFileName As String
  On Error Resume Next
  Application.ScreenUpdating = False
  Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
  If xDlg.Show <> -1 Then Exit Sub
  xFldPath = xDlg.SelectedItems(1) + "\"
  Call ListAllFiles(xFldPath)
  Application.ScreenUpdating = True
End Sub

Function ListAllFiles(FldPath)
  Dim xFSO As FileSystemObject
  Dim xFolder As Folder
  Dim xSubFolder As Folder
  Dim xNewName As String
  On Error Resume Next
  xFileName = Dir(FldPath & "*.doc", vbNormal)
  While xFileName <> ""
    xNewName = VBA.Left$(xFileName, VBA.InStrRev(xFileName, "doc") - 1) & "docx"
    Documents.Open FileName:=FldPath & xFileName, _
        ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
        PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
        WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
        wdOpenFormatAuto, XMLTransform:=""
    ActiveDocument.SaveAs FldPath & xNewName, wdFormatDocumentDefault
    ActiveDocument.Close
    xFileName = Dir()
  Wend
  Set xFSO = CreateObject("Scripting.FileSystemObject")
  Set xFolder = xFSO.GetFolder(FldPath)
  For Each xSubFolder In xFolder.SubFolders
    Call ListAllFiles(xSubFolder.Path + "\")
  Next
  Set xFSO = Nothing
  Set xFolder = Nothing
End Function
This comment was minimized by the moderator on the site
Nice tool but I got the problem, that I can't convert DOC files (written in capitals!) into docx files.
It works with doc files.
This comment was minimized by the moderator on the site
Hi,
The following code can help to convert both doc. and DOC. files into docx files. Please give it a try. Thanks for your feedback.

Sub ConvertDocToDocx()
'Updated by ExtendOffice 20220506
    Dim xDlg As FileDialog
    Dim xFolder As Variant
    Dim xFileName As String
    Application.ScreenUpdating = False
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show <> -1 Then Exit Sub
    xFolder = xDlg.SelectedItems(1) + "\"
    xFileName = Dir(xFolder & "*.doc", vbNormal)
    While xFileName <> ""
        Documents.Open FileName:=xFolder & xFileName, _
            ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
            PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
            WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
            wdOpenFormatAuto, XMLTransform:=""
        ActiveDocument.SaveAs xFolder & Replace(VBA.LCase(xFileName), "doc", "docx"), wdFormatDocumentDefault
        ActiveDocument.Close
        xFileName = Dir()
    Wend
    Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Thanks for sharing
This comment was minimized by the moderator on the site
best graphic design company in india
Designing is a craft of communicating words as articulations. Visuals matter more than words in the advanced field.
The experts in the designing business recommend that illustrations are simpler to recall than words,
and that is the reason Website designing and Graphics play an imperative job.

This comment was minimized by the moderator on the site
Thanks for sharing this useful information.
This comment was minimized by the moderator on the site
This is really insightful article , found it very helpful and informational
This comment was minimized by the moderator on the site
HelloNice post .. Keep sharing.Thank You
This comment was minimized by the moderator on the site
Hello sir,
I love with this post.I really appreciate for this website.Your information is so good and valuable.Lovable idea and concept for sharing this website.
This is an amazing website.This post is nice.
Thanks for sharing
This comment was minimized by the moderator on the site
Hi....Hi, This blog content very technical information, it is on of the best blog i have got. Very interesting and describe in a very easy way.
This comment was minimized by the moderator on the site
Hello,
I am glad to find this useful information Thanks for sharing this amazing article.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations