- 帖子
- 472
- 主題
- 5
- 精華
- 0
- 積分
- 485
- 點名
- 0
- 作業系統
- Windows
- 軟體版本
- MS Office
- 閱讀權限
- 100
- 性別
- 男
- 來自
- 香港
- 註冊時間
- 2010-7-4
- 最後登錄
- 2014-12-28

|
我指的是程式執行時,
會自動讀取指定路徑的word檔案,
並把檔案寫回Excel上面,
但我希望他的格式不會變 ...
kannas 發表於 2010-12-1 01:05 
一個非常懶的方法
copy and paste....- Sub dsa()
- Dim Wd 'Word
- Dim Dc '文件
- Dim Tb '內表
- Dim i, j '定位
-
- Sheet1.UsedRange.EntireRow.Delete 'Excel Sheet1 清表
- Set Wd = CreateObject("Word.Application")
- Dim RgR As Range
- Set Dc = Wd.Documents.Open("C:\temp\1.DOC ") '檔名
- Wd.Visible = True
- With Wd.Selection.Find
- .Text = "^l"
- .Replacement.Text = " "
- End With
- Wd.Selection.Find.Execute Replace:=2
- With Wd.Selection.Find
- .Text = "^p"
- .Replacement.Text = " "
- End With
- Wd.Selection.Find.Execute Replace:=2
- For Each Tb In Dc.tables
- Set RgR = Sheet1.UsedRange.EntireRow.Offset(Sheet1.UsedRange.Rows.Count + 1, 0).Cells(1)
- Tb.Range.Copy
- RgR.Select
- ActiveSheet.PasteSpecial Format:="HTML"
- Next
-
- Wd.Quit
- End Sub
複製代碼 |
|