首页 > 解决方案 > VBA 库未注册运行时错误“-2147319779 (8002801d)”

问题描述

`我目前使用以下 VBA 来创建我的季度报告。

'Dim ppApp As PowerPoint.Application   
 Dim ppSlide As PowerPoint.Slide
 Dim shp As Object
 Dim myTextBox As Object
 Dim PPTTitle As String
 Dim PPTFooter As String
 Dim i As Integer
 Dim q As Integer
 Dim ChrtstoCopy As Integer
 Dim TblstoCopy As Integer
 Dim Firstslide As Boolean
 Dim CurrentSite As String
 Dim shortDeptName As String
 Sub CopytoPPT(Lbox_Exp, Lbox_Lis, Lbox_Rec)

 'ACTIVATED BY: Userform2 Command Button
 'PURPOSE: Copy the printareas for slides 1-5 in picture format and then 
  paste to a PPT slide.

 'Identify the criteria for the PPT slides
  CurrentSite = UserForm2.SiteTbox.Value
  ChrtstoCopy = Slide1_Sht.Range("S19").Value - 1
  TblstoCopy = Slide5_Sht.Range("D5").Value
  Firstslide = True
  If UserForm2.CheckBox1 = True Then
  blinded = " (Blinded)"
  Else
  blinded = " (Unblinded)"
  End If

 shortDeptName = 
 TgtSht.Range("SaveFileName").Find(What:=CurrentSite).Offset(0, 1).Text
 fileNameString = TgtSht.Range("SaveFolder") & TgtSht.Range("SavePrefix") & 
  " - " & shortDeptName

  'Open PPT application and existing blank PPT template file
   Set ppApp = New PowerPoint.Application
   ppApp.Visible = True 

VBA 用于将我的数据粘贴到 power point 中呈现的图表中。最近我的桌面更新为 64 位,当我尝试运行我的 VBA 来生成我需要的电源点时,它给了我以下错误消息。运行时错误“-2147319779 (8002801d)”:自动化错误库未注册

我试图进一步调查可能导致此问题的原因,我认为这可能与命令“Set ppApp = New PowerPoint.Application”有关。

当我尝试只为 PasteImgtoPPT 运行宏时,我收到运行时错误“91”:对象变量或块变量未设置错误。

我已经尝试了数周来修复这个 VBA,但似乎找不到解决方案。任何帮助将不胜感激!

标签: excelvba

解决方案


很可能您在项目中没有Microsoft Powerpoint引用,因此尝试声明引用 powerpoint 的变量将失败(您的项目不知道那是什么)。

要告诉你的项目(做参考)去工具>>参考并在列表中找到它:

在此处输入图像描述

检查它,然后单击“确定”,然后尝试再次执行您的 VBA。

您还可以考虑后期绑定您的 powerpoint 变量,这样您就不必引用它们:

 Dim ppApp As Object  
 Dim ppSlide As Object
 Set PPApp = CreateObject("PowerPoint.Application")
 Set ppSlide = PPApp.Slide

CreateObjectPowerpoint.Application在运行时加载对的引用。


推荐阅读