肿么用vba实现在word中插入excel表格

excelwordVBA

1个回答

写回答

wuli娘

2026-02-16 03:45

+ 关注

excel
excel

Sub AA() Dim projectno As String, projectname As String, datereceive As Dat静怎脸各毫配源乙转太湖e, datecomplate As Date, functionary As String Dim arr As Object Dim i As Long Dim brr projectno = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables(1).Cell(1, 2).Range

Dim excelobject As Object Set excelobject = GetObject("D:Downloadsproject(word)p兴力李蒸划祖征宗结roject.xls") Set arr = excelobject.Sheets(1).usedrange()

brr = arr

word
word

For i = 2 To UB增想始林友ound(brr) If InStr(1, projectno, brr(i, 1)) 0 Then projectname = brr(i, 2) datereceive = brr(i, 3) datecomplate = brr(i, 4) functionary = brr训坏殖倒拉减(i, 5) Exit For End If Next 星绝语温亮i

ActiveDo行报善满不川黄冲重植cument.Tables(1).Cell(1, 2).Range = projectname ActiveDocument.Tables(1).Cell(2, 2).Range = datereceive ActiveDocument.Tables(1).Cell(3, 2).Range = datecomplate ActiveDocument.Tables(1).Cell(4, 2).Range = functionary

excelobje火密画ct.Close False

End Sub

举报有用(6分享收藏

Copyright © 2025 IZhiDa.com All Rights Reserved.

知答 版权所有 粤ICP备2023042255号