查看積分策略說明發表回覆
Discuz! 代碼
提示插入
直接插入
說明訊息

插入粗體文本 插入斜體文本 插入下劃線 置中對齊 插入超級連結 插入信件位址 插入圖像 插入 flash 插入代碼 插入引言 插入列表
刪除線 直線分隔線 虛線分隔線
    
添加文字底框
內容 [字數檢查]:

表情符號

更多 Smilies
字型大小 |||
溫馨提示:本區開放遊客瀏覽。


文章關鍵字 : [功能說明]
(關鍵字可加強搜索準確性, 如關鍵字多於一組, 請以 , 作分隔, e.g. : 阿笨,shiuh,第一笨)

 關閉 URL 識別 | html 禁用
 關閉 表情符號 | 表情符號 可用
 關閉 Discuz! 代碼 | Discuz! 代碼 可用
使用個人簽名
接收新回覆信件通知
推薦放檔網絡空間

檔案(Torent, zip等)
  1. freedl
  2. multiupload
  3. btghost
  4. 便當狗
  5. mediafire
  6. pillowangel
圖片(JPG, GIF等)
  1. hotimg
  2. tinypic
  3. mousems2
  4. imageshack
  5. imm.io
>>>歡迎推薦好用空間


最新10篇文章回顧
acrd

 發表於 2023-3-5 12:32 AM

chatgpt

Function GetAllDocFiles(folderPath As String) As String()
    ' 搜尋指定目錄及其子目錄下所有 .doc 檔案的路徑
    Dim fileNames() As String
    ReDim fileNames(0)

    Dim fileName As String
    fileName = Dir(folderPath & "\*.doc", vbNormal)

    While fileName <> ""
        If fileName <> "." And fileName <> ".." Then
            ' 將找到的 .doc 檔案加入陣列中
            fileNames(UBound(fileNames)) = folderPath & "\" & fileName
            ReDim Preserve fileNames(UBound(fileNames) + 1)
        End If
        fileName = Dir()
    Wend

    Dim subFolderPath As String
    subFolderPath = Dir(folderPath & "\*", vbDirectory)

    While subFolderPath <> ""
        If subFolderPath <> "." And subFolderPath <> ".." Then
            ' 如果是目錄,就遞迴呼叫本身搜尋該目錄
            If (GetAttr(folderPath & "\" & subFolderPath) And vbDirectory) = vbDirectory Then
                Dim subFolderFiles() As String
                subFolderFiles = GetAllDocFiles(folderPath & "\" & subFolderPath)
                If UBound(subFolderFiles) > -1 Then
                    ' 將子目錄中找到的 .doc 檔案加入陣列中
                    Dim i As Integer
                    For i = 0 To UBound(subFolderFiles)
                        fileNames(UBound(fileNames)) = subFolderFiles(i)
                        ReDim Preserve fileNames(UBound(fileNames) + 1)
                    Next i
                End If
            End If
        End If
        subFolderPath = Dir()
    Wend

    If UBound(fileNames) > 0 Then
        ReDim Preserve fileNames(UBound(fileNames) - 1)
    Else
        ReDim fileNames(-1)
    End If
   
    GetAllDocFiles = fileNames
End Function

Sub ConvertDocToDocx()
    ' 將所有 .doc 檔案轉換為 .docx 檔案
    Dim fileNames() As String
    fileNames = GetAllDocFiles("C:\My Documents") ' 指定搜尋目錄

    Dim fileName As String
    For Each fileName In fileNames
        Dim doc As Document
        Set doc = Documents.Open(fileName)
        doc.SaveAs2 FileName:=Replace(fileName, ".doc", ".docx"), FileFormat:=wdFormatXMLDocument
        doc.Close
    Next fileName
End Sub


這個程式會搜尋指定的目錄及其子目錄下所有 .doc 檔案,並將其轉換為 .docx 格式。如果您希望搜尋的目錄不同,請將 GetAllDocFiles 函數中的 folderPath 變數設定為該目錄的路徑。注意,這個程式會將找到的所有 .doc 檔案都轉換為 .docx 格式,請務必備份原始檔案。

[acrd 在  2023-3-5 12:44 AM 作了最後編輯]


ADSLX2

 發表於 2020-11-24 05:21 PM

pip pypI 應有 dosx 的 package


alonewalker

 發表於 2020-9-9 03:57 PM

感謝你。


引用:
Logger寫到:
3  Quick Ways to Batch Convert Word DOC to DOCX Files and Vice Versa
https://datanumen.com/blogs/3-qu ... les-and-vice-versa/


Logger

 發表於 2020-9-8 07:38 PM

3  Quick Ways to Batch Convert Word DOC to DOCX Files and Vice Versa
https://datanumen.com/blogs/3-qu ... les-and-vice-versa/


alonewalker

 發表於 2020-9-7 01:46 AM

因為個人需要
要將手上很多WORD檔案(分散在很多資料夾與子資料夾),目前都是DOC檔案(就是附檔名為.doc)

想要做到
1.轉換成也是WORD的DOCX檔案(就是附檔名為.docx)
2.而且轉換完後自動儲存在原先DOC檔案的檔案夾內

譬如說
A資料夾--1資料夾--有a.doc b.doc
          --2資料夾--有a.doc b.doc

自己之前都是笨笨的一個個打開,再一個個另存成DOCX檔案
目前自己研究也爬文了一段時間,只能針對單一資料夾內進行轉檔

不知道有沒有程式,可以達成上述功能???
上來問問大家
自己常用的是VBA或python,當然如果大大有其他程式語言可以達到上面功能,也能給小弟指點迷津,感謝。
(給程式碼或是大概的做法都可以,線上自動轉檔網站我就不列入考慮)

[alonewalker 在  2020-9-7 09:54 AM 作了最後編輯]





所在時區為 GMT+8, 現在時間是 2024-3-29 12:46 AM
清除 Cookies - 連絡我們 - TWed2k © 2001-2046 - 純文字版 - 說明
Discuz! 0.1 | Processed in 0.022402 second(s), 7 queries , Qzip disabled