返回列表 上一主題 發帖

如何利用excel 控制 word呢?

如何利用excel 控制 word呢?

請問各位大大,利用excel產生介面後,如何控制word呢?

是這樣的,小的在工作上需使用範本更改內容,產生新的檔案,需使用excel及word∼

能否在excel設計出介面後,呼叫word,並控制更改word內容呢?

問題太模糊!
Word呈現極致的靜態之美,Excel展現極致的動態之美。

TOP

Dim Wordapp As Word.Application
    Set Wordapp = New Word.Application      '新建Word物件
    Wordapp.Visible = True                    '可見

    Dim WordD As Word.Document      '定義word類
    Set WordD = Wordapp.Documents.Add       '新建文件

    Wordapp.Selection.WholeStory  '全選
    Wordapp.Selection.Font.Name = "字體名
    Wordapp.Selection.Font.Size = 16   '字尺寸

TOP

他的意思是不是把EXCEL設計好的版面 出成WORD內容?
以後只要改EXCEL ,WORD內容自動改變?

TOP

合併列印功能

TOP

因為權限不足不能貼連結,請自行複製
youtu.be/Stbqrk7PlGU

希望對你有幫助唷!

TOP

Sub 發文()

Dim myStr As String
Dim myran As Range

On Error Resume Next
Set myran = Application.InputBox(prompt:="圈選範圍", Type:=8)

myrow = myran.Row
mycol = myran.Column
mynum = myran.Rows.Count

'myfn = Cells(myrow, mycol - 1).Value

'For Each mye In myran

'If myStr = "" Then
'myStr = mye.Value
'Else: myStr = myStr & "、" & mye.Value
'End If
'Next
For i = 1 To mynum
mywd1 = Cells(myrow + i - 1, mycol).Value
mywd2 = Cells(myrow + i - 1, mycol + 1).Value
mywd3 = Cells(myrow + i - 1, mycol + 2).Value
mywd4 = Cells(myrow + i - 1, mycol + 4).Value
mywd5 = Cells(myrow + i - 1, mycol + 5).Value



Dim myWord As New Word.Application

myWord.Visible = True

Set mydoc = myWord.Documents.Open("desktop\1.公文\公文.DOC")

With mydoc.Content.Find
.Text = "MYWORD1"
.Replacement.Text = mywd1
Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.Execute Replace:=wdReplaceAll
End With

With mydoc.Content.Find
.Text = "MYWORD2"
.Replacement.Text = mywd2
Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.Execute Replace:=wdReplaceAll
End With

With mydoc.Content.Find
.Text = "MYWORD3"
.Replacement.Text = mywd3
Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.Execute Replace:=wdReplaceAll
End With

With mydoc.Content.Find
.Text = "MYWORD4"
.Replacement.Text = mywd4
Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.Execute Replace:=wdReplaceAll
End With

With mydoc.Content.Find
.Text = "MYWORD5"
.Replacement.Text = mywd5
Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.Execute Replace:=wdReplaceAll
End With




mydoc.SaveAs Filename:="desktop\1.公文\公文" & mywd1 & mywd3
Next i
End Sub

TOP

        靜思自在 : 人事的艱難與琢磨,就是一種考驗。
返回列表 上一主題