other
mura vba insert word into a specific place in microsoft word
Sub CopyToWord()
Dim wordApp As Word.Application
Set wordApp = CreateObject("Word.Application")
wordApp.Visible = True
Dim wordDoc As Word.Document
Dim target_doc As String
target_doc = Dir(ThisWorkbook.Path & "" & "*.doc")
Do While target_doc <> ""
Set wordDoc = wordApp.Documents.Open(ThisWorkbook.Path & "" & target_doc)
'æ–‡å—列を検索
Dim x As Variant
'placeholderを検索ã—ã€ãã“ã«ã‚«ãƒ¼ã‚½ãƒ«ã‚’移動
With wordApp.Selection.Find
.Text = "placeholder"
.Execute
End With
'1行下ã«ãƒ€ã‚¦ãƒ³
wordApp.Selection.MoveDown
'1行全体をé¸æŠž
wordApp.Selection.Expand Unit:=wdSection
'1行消去
wordApp.Selection.Delete
'æ–‡å—ã®å…¥åŠ›
wordApp.Selection.TypeText "ç½®æ›å¾Œã®æ–‡å—列1"
'ワードファイルを閉ã˜ã‚‹
wordDoc.Close
wordApp.Visible = False
'Set wordApp = Nothing
target_doc = Dir()
Loop
End Sub
Was this helpful?
Similar Posts