返回列表 上一主題 發帖

如何將excel Range(a1) 貼到 word 上

如何將excel Range(a1) 貼到 word 上

Private Sub CommandButton1_Click()
    Dim myTmpFName As String
    myTmpFName = ThisWorkbook.Path & Application.PathSeparator _
        & "test文件.dot"
     With New Word.Application                     
                With .Documents.Add(myTmpFName)
                     .Unprotect
                     .Tables(2).Cell(1, 1).Range.Text =  Worksheets("sheet1").Range(a1)
                     .Protect wdAllowOnlyFormFields
               End With
         .Visible = True
      End With
   End Sub

用     .Tables(2).Cell(1, 4).Range.Text =  Worksheets("sheet1").Range(a1)    貼不上
要怎麼寫 請教各位高手  謝謝!
max

試試把
                 .Tables(2).Cell(1, 1).Range.Text =  Worksheets("sheet1").Range(a1)
改成
                 .Tables(2).Cell(1, 1).Range.Text =  Worksheets("sheet1").Range("a1")
懂得發問,答案就會在其中

今日の一秒は  明日にない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

謝謝您,沒基礎的初學者,感謝!
max

TOP

        靜思自在 : 不怕事多,只怕多事。
返回列表 上一主題