Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel InsertFormula公式:="=总和(以上)“;_Excel_Vba_Ms Word - Fatal编程技术网

Excel InsertFormula公式:="=总和(以上)“;

Excel InsertFormula公式:="=总和(以上)“;,excel,vba,ms-word,Excel,Vba,Ms Word,我目前正在阅读一个excel表格,并在MS word中生成一个表格,其中包含来自excel表格的匹配记录。我有88%的时间在那里,但我有和问题,插入一个公式到一个细胞 LastProdHistRow = LastProdHistRow + 6 ' Adding additional rows to production history table Set rRange = objDoc.Bookmarks(BkProdHist).Range Set tblNew =

我目前正在阅读一个excel表格,并在MS word中生成一个表格,其中包含来自excel表格的匹配记录。我有88%的时间在那里,但我有和问题,插入一个公式到一个细胞

LastProdHistRow = LastProdHistRow + 6               ' Adding additional rows to production history table
Set rRange = objDoc.Bookmarks(BkProdHist).Range
Set tblNew = objDoc.Tables.Add(Range:=rRange, NumRows:=LastProdHistRow, NumColumns:=10)




objDoc.Tables(2).Cell(3, 1).Range.Text = "Date"
objDoc.Tables(2).Cell(3, 2).Range.Text = "Volume"
objDoc.Tables(2).Cell(3, 3).Range.Text = "Begin Bates"
objDoc.Tables(2).Cell(3, 4).Range.Text = "End Bates"
objDoc.Tables(2).Cell(3, 5).Range.Text = "Documents"
objDoc.Tables(2).Cell(3, 6).Range.Text = "Redactions"
objDoc.Tables(2).Cell(3, 7).Range.Text = "Pages"
objDoc.Tables(2).Cell(3, 8).Range.Text = "Images"
objDoc.Tables(2).Cell(3, 9).Range.Text = "Natives"
objDoc.Tables(2).Cell(3, 10).Range.Text = "Slip-Sheets"
'objDoc.Tables(2).Cell(3, 11).Range.Text = "Size"
'objDoc.Tables(2).Cell(3, 12).Range.Text = "MB"
'objDoc.Tables(2).Cell(3, 13).Range.Text = "Bytes"
objDoc.Tables(2).Cell(LastProdHistRow + 6, 4).Range.Text = "Totals"
'************** End - Create Table with Production History



'Begin************** Copy Production History Array to  Word Table *************************

a = 4           ' The starting row of the table to begin copying data
For x = LBound(LastProdHist, 1) To UBound(LastProdHist, 1)
    b = 1
        For y = LBound(LastProdHist, 2) To UBound(LastProdHist, 2)
            Debug.Print x, y, LastProdHist(x, y)
            objDoc.Tables(2).Cell(a, b).Range.Text = LastProdHist(x, y)
            b = b + 1
        Next y
        a = a + 1
    Next x

'End**************  Produciton History Array to Word table ****************************
 
 
  With objDoc.Tables(2)
    .Rows(2).Cells.Merge
    .Cell(2, 1).Range.Text = "DOCUMENT PRODUCTION HISTORY"
    .Cell(2, 1).Range.Style = ("Heading 1")
    .Rows(3).Range.Font.Bold = True
    .Cell(LastProdHistRow, 4).Range.ParagraphFormat.Alignment = wdAlignParagraphRight
    **'Cell(LastProdHistRow, 5).Range.InsertFormula Formula:="=SUM(ABOVE)", NumberFormat:=""**
    .Rows(LastProdHistRow).Borders(wdBorderTop).LineStyle = wdLineStyleSingle
    .Rows(LastProdHistRow).Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
    '.Cell(LastProdHistRow, 5).Select
    'Selection.InsertFormula Formula:="=SUM(ABOVE)", NumberFormat:=""
    .Rows.SetLeftIndent LeftIndent:=0.5, RulerStyle:=wdAdjustNone
    '.Columns(10).SetWidth ColumnWidth:=64.65, RulerStyle:=wdAdjustNone
        
End With
我得到一个运行时错误438-对象在表的with语句中使用时不支持此属性或方法

单元格(LastProdHistRow,5)。Range.InsertFormula公式:=“=总和(以上)”,NumberFormat:=”

我还尝试选择它作为
With
语句中的最后一行,并应用插入公式。但是得到同样的错误

”。单元格(LastProdHistRow,5)。选择“Selection.InsertFormula:=”=SUM(上)”,NumberFormat:=”


有谁能提供一个线索,让这项工作的下一步?提前谢谢。

单元格上没有
插入公式
方法

试试这个:

.Cell(LastProdHistRow, 5).Formula Formula:="=Sum(Above)"

这很奇怪,我录制了一个宏,它给了我InsertFormula方法。好好工作,谢谢蒂姆!3天的无用搜索。InsertFormula仅为选择方法。