0

全部,

我的任务是从 2003 年升级到 2007 年的 Access。数据库的目的是创建一个从 excel 电子表格自动生成的数据的 power point 演示文稿。我可以导入数据,但是在尝试将其生成到电源点时,我收到错误消息。尝试从 excel 电子表格中获取数据并将其放入 power point 演示文稿的表格中时,似乎会发生错误。这段代码是由其他人完成的,我不确定这两个版本之间有什么不同。请帮忙!以下所有内容都是代码的一部分..不太清楚为什么它会以这种方式分开..对不起。如果您需要更多信息,请告诉我。请参阅下面的错误和代码:

错误:运行时错误 -2147467259 (800004005) 对象“形状”的方法“表”失败

'Replace all tags with values from datarow
  With shape.Table

        .Cell(1, 1).shape.TextFrame.TextRange.Text = Replace(.Cell(1, 1).shape.TextFrame.TextRange.Text, "<ID>", ID)
        .Cell(1, 3).shape.TextFrame.TextRange.Text = Replace(.Cell(1, 3).shape.TextFrame.TextRange.Text, "<TITLE>", TITLE)
        .Cell(2, 1).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 1).shape.TextFrame.TextRange.Text, "<STATUS>", status)
        .Cell(2, 1).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 1).shape.TextFrame.TextRange.Text, "<OWNER>", OWNER)
' is part of WBS in cost changes (Perry Sedlar)            
        .Cell(2, 1).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 1).shape.TextFrame.TextRange.Text, "<REP>", REP)
        .Cell(2, 1).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 1).shape.TextFrame.TextRange.Text, "<ACTION>", ACTION)    
' Shifted to the left after removing Gov't Rep column (Perry Sedlar)
        .Cell(2, 3).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 3).shape.TextFrame.TextRange.Text, "<MCE>", MCE)
        .Cell(2, 3).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 3).shape.TextFrame.TextRange.Text, "<ISSUE>", ISSUE)
' is part of WBS in cost changes (Perry Sedlar)          
        .Cell(2, 3).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 3).shape.TextFrame.TextRange.Text, "<ACTION>", ACTION) 
' Shifted to the left after removing Gov't Rep column (Perry Sedlar)
        .Cell(2, 3).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 3).shape.TextFrame.TextRange.Text, "<PM>", PM)0 
' Shifted to the left after removing Gov't Rep column (Perry Sedlar)
        .Cell(2, 5).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 5).shape.TextFrame.TextRange.Text, "<HA>", HA)
        .Cell(2, 5).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 5).shape.TextFrame.TextRange.Text, "<MP>", MP)
' is part of WBS in cost changes (Perry Sedlar)                      
        .Cell(2, 5).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 5).shape.TextFrame.TextRange.Text, "<PM>", PM) 
' Shifted to the left after removing Gov't Rep column (Perry Sedlar)
        .Cell(2, 5).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 5).shape.TextFrame.TextRange.Text, "<LVL>", LVL) 
' Shifted to the left after removing Gov't Rep column (Perry Sedlar)
        .Cell(2, 8).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 8).shape.TextFrame.TextRange.Text, "<PROB>", Prob)
        .Cell(2, 8).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 8).shape.TextFrame.TextRange.Text, "<EXP>", EXP)
' is part of WBS in cost changes (Perry Sedlar)                      
       .Cell(2, 8).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 8).shape.TextFrame.TextRange.Text, "<LVL>", LVL)
        .Cell(3, 1).shape.TextFrame.TextRange.Text = Replace(.Cell(3, 1).shape.TextFrame.TextRange.Text, "<DESCRIPTION>", DESC)
        .Cell(4, 10).shape.TextFrame.TextRange.Text = Replace(.Cell(4, 10).shape.TextFrame.TextRange.Text, "<C>", C)
        .Cell(4, 10).shape.TextFrame.TextRange.Text = Replace(.Cell(4, 10).shape.TextFrame.TextRange.Text, "<S>", S)
        .Cell(4, 10).shape.TextFrame.TextRange.Text = Replace(.Cell(4, 10).shape.TextFrame.TextRange.Text, "<T>", T)
        .Cell(4, 10).shape.TextFrame.TextRange.Text = Replace(.Cell(4, 10).shape.TextFrame.TextRange.Text, "<O>", o)
        .Cell(2, 8).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 8).shape.TextFrame.TextRange.Text, "<ARO>", Trend_Arrow)



        If IssueFileRead = "N" Then ' Check to see if running Issue or Risk..  templates are now different (Perry Sedlar)

            ' This code is for Risk Slides (Perry Sedlar)
            .Cell(2, 1).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 1).shape.TextFrame.TextRange.Text, "<OCCUR>", OCCUR)
            .Cell(2, 1).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 1).shape.TextFrame.TextRange.Text, "<OCCUR_FACT>", OCCUR_FACT)
            .Cell(2, 3).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 3).shape.TextFrame.TextRange.Text, "<MIT>", MIT)
            .Cell(2, 3).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 3).shape.TextFrame.TextRange.Text, "<MIT_FACT>", MIT_FACT)
            .Cell(2, 5).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 5).shape.TextFrame.TextRange.Text, "<OPP>", OPP)
            .Cell(2, 5).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 5).shape.TextFrame.TextRange.Text, "<OPP_FACT>", OPP_FACT)
            .Cell(2, 7).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 7).shape.TextFrame.TextRange.Text, "<IPT>", IPT)
            .Cell(2, 7).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 7).shape.TextFrame.TextRange.Text, "<WBS>", WBS)
        Else

            ' This code if for Issue Slides (Perry Sedlar)
            .Cell(2, 1).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 1).shape.TextFrame.TextRange.Text, "<REP>", REP)
            .Cell(2, 3).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 3).shape.TextFrame.TextRange.Text, "<ACTION>", ACTION) ' Shifted to the left after removing Gov't Rep column (Perry Sedlar)
            .Cell(2, 5).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 5).shape.TextFrame.TextRange.Text, "<PM>", PM) ' Shifted to the left after removing Gov't Rep column (Perry Sedlar)
            .Cell(2, 8).shape.TextFrame.TextRange.Text = Replace(.Cell(2, 8).shape.TextFrame.TextRange.Text, "<LVL>", LVL)
        End If

    End With
End Sub
4

2 回答 2

0

代码库不同,其中某些语法不允许使用。从 2003 年到 2007 年,DAO 也有所不同。需要对程序进行重写才能使其正常工作。谢谢您的帮助。

于 2013-05-09T14:59:33.023 回答
0

“对象‘形状’的方法‘表’失败”

我们可能需要在错误发生之前查看代码。您是否设置了对形状的引用并确保该形状实际上是一张桌子?

此外,由于 Shape 是保留字,我会使用其他名称作为变量名。

Dim oSh as Shape
Dim oTbl as Table
Set oSh = [fill in the blank here ... your call]
If oSh.HasTable Then
  Set oTbl = oSh.Table
  With oTbl
    ' [ do your stuff here ]
  End With
Else
  MsgBox "OOpsie.  Barking up the wrong shape here."
End If

如果这需要从 Excel 到 PPT,您的预算在 70 美元左右,并且想要快速完成它并且不通过 Access,请查看http://www.pptools.com/merge/

完全披露:这是我编写/销售的商业产品。
(主持人:如果不能接受,请随意打最后两段)

于 2013-04-27T02:04:39.433 回答