Opomba: Drugi jeziki spletnega mesta so prevedeni z Googlom. Nazaj na angleščino
Vpiši se  \/ 
x
or
x
Registracija  \/ 
x

or

Kako paketno pretvoriti Wordove dokumente v datoteko txt?

Ta članek govori o tem, kako paketno pretvoriti vse Wordove dokumente v določeni mapi v ločene datoteke TXT v Wordu.

Paketno pretvorite Wordove dokumente v datoteke txt z VBA


Paketno pretvorite Wordove dokumente v datoteke txt z VBA

Spodnja koda VBA vam lahko pomaga pretvoriti vse Wordove dokumente v določeni mapi v datoteke txt hkrati. Naredite naslednje.

1. V Wordovem dokumentu pritisnite druga + F11 tipke za odpiranje Microsoft Visual Basic za aplikacije okno.

2. V Ljubljani Microsoft Visual Basic za aplikacije okno, kliknite Vstavi > Moduli, nato kopirajte spodnjo kodo v okno modula.

Koda VBA: paketno pretvorite Wordove dokumente v datoteke txt

Sub ConvertDocumentsToTxt()
'Updated by Extendoffice 20181123
    Dim xIndex As Long
    Dim xFolder As Variant
    Dim xFileStr As String
    Dim xFilePath As String
    Dim xDlg As FileDialog
    Dim xActPath As String
    Dim xDoc As Document
    Application.ScreenUpdating = False
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show <> -1 Then Exit Sub
    xFolder = xDlg.SelectedItems(1)
    xFileStr = Dir(xFolder & "\*.doc")
    xActPath = ActiveDocument.Path
    While xFileStr <> ""
        xFilePath = xFolder & "\" & xFileStr
        If xFilePath <> xActPath Then
            Set xDoc = Documents.Open(xFilePath, AddToRecentFiles:=False, Visible:=False)
            xIndex = InStrRev(xFilePath, ".")
            Debug.Print Left(xFilePath, xIndex - 1) & ".txt"
            xDoc.SaveAs Left(xFilePath, xIndex - 1) & ".txt", FileFormat:=wdFormatText, AddToRecentFiles:=False
            xDoc.Close True
        End If
        xFileStr = Dir()
    Wend
    Application.ScreenUpdating = True
End Sub

3. Pritisnite F5 tipko za zagon kode.

4. V Ljubljani Brskanje izberite mapo, v kateri so Wordovi dokumenti, ki jih želite pretvoriti v datoteke txt, in kliknite OK . Oglejte si posnetek zaslona:

Nato lahko vidite, da se vsi dokumenti v izbrani mapi hkrati pretvorijo v datoteke txt. Oglejte si posnetek zaslona:



Priporočena orodja za produktivnost besed

 

Kutools za Word - več kot 100 naprednih funkcij za Word prihranite 50% časa

  • Zapletene in ponavljajoče se operacije je mogoče enkrat obdelati v nekaj sekundah.
  • V Wordov dokument hkrati vstavite več slik v mape.
  • Združite in združite več datotek Word v mapah v eno z želenim vrstnim redom.
  • Trenutni dokument razdelite na ločene dokumente glede na naslov, prelom odseka ali druga merila.
  • Pretvarjanje datotek med dokumenti Doc in Docx, Docx in PDF, zbirka orodij za pogoste pretvorbe in izbiro itd. ...

Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Mina · 3 months ago
    Not working for me, any ideas why?
    Do I need to do this in a word document from the same folder I want to convert or any new word document that I start? -Tried both options and none is working but I am also not getting any error messages

    • To post as a guest, your comment is unpublished.
      mIk · 2 months ago
      Change xFileStr = Dir(xFolder & "\*.doc") to xFileStr = Dir(xFolder & "\*.docx") as i assume you have newer word files format.
    • To post as a guest, your comment is unpublished.
      Mina · 3 months ago
      I'm using windows 10 and Microsoft office 2016
  • To post as a guest, your comment is unpublished.
    DebSutter · 3 months ago
    Thank you! This is extremely helpful
    • To post as a guest, your comment is unpublished.
      Mina · 3 months ago
      How did you get it to work?
  • To post as a guest, your comment is unpublished.
    Mario · 1 years ago
    I'm a fan of poetry. I needed to convert more than 700 word compositions to txt. Thanks to your subroutine I managed to do it in no time.
    Thank you