2013-04-26 101 views
0

所有,升級DB從Access 2003中訪問2007年

我一直負責到Access升級從2003年到2007年的DB的目的是創建一個自動從生成數據的Power Point演示Excel電子表格。我能夠導入數據,但是當試圖將其生成到電源點時,我收到一個錯誤。看起來像是在嘗試從Excel電子表格中獲取數據並將其放入Powerpoint演示文稿的表格中時發生錯誤。此代碼由其他人完成,我不確定這兩個版本之間有什麼不同。請幫忙!以下全部是代碼的一部分..不太確定爲什麼它將它的方式分開..接受。讓我知道如果你需要更多的信息。看到錯誤代碼和下面:

錯誤:運行時錯誤-2147467259(800004005) Method對象「形狀」的「表」失敗

'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 

回答

0

「方法‘表’對象‘形狀’的失敗「

我們可能需要在發生錯誤之前查看代碼。你有沒有設置一個形狀的參考,並確保形狀實際上是一個表?

此外,由於形狀是一個保留字,我會使用別的東西作爲變量名。

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塊錢左右的預算,並希望得到它快速和W做/ O通過Access去,看看http://www.pptools.com/merge/

充分披露:這是我寫/賣的商業產品。
(主持人:如果提到這是不可接受的,可以隨意敲掉最後兩段)

+0

對不起,我只是回來與你。上週我整個星期都在接受訓練。有沒有一種方法可以將所有代碼放入代碼中,而不會讓代碼太長而無法使用評論框? – user2324835 2013-05-06 12:45:48

+0

此外,我試過你的代碼,它說oSh.HasTable,我收到一個編譯錯誤:找不到方法或數據成員 – user2324835 2013-05-06 15:05:22

0

代碼庫不同,並且有些語法不允許使用。 DAO也與2003年到2007年不同。需要重新編寫程序才能正常工作。謝謝您的幫助。