none
Excel VBA 2013 does not work on Office 2010 RRS feed

  • Question

  • Hi,

    I have several modules in Excel 2013 that produce other Excel files and PowerPoint files. I tested this on some computers with Office 2013 and there everything also worked.

    Now I wanted to test this on a computer with Office 2010, but then it failed and said it could not open the application.

    The code:

    Sub PowerPointSub1()
    
        'First we declare the variables we will be using
            Dim newPowerPoint As PowerPoint.Application
            Dim activeSlide As PowerPoint.Slide
            Dim cht As Excel.ChartObject
            
         'Define worksheets
         Set WB = ThisWorkbook
         Set WSIndex = WB.Worksheets(1)
         Set WSNumOfOpp = WB.Worksheets(6)
         Set WSFleetPerfOne = WB.Worksheets(7)
         Set WSFleetPerfTwo = WB.Worksheets(8)
         Set WSATA = WB.Worksheets(9)
         Set WSBench = WB.Worksheets(10)
         
         'Look for existing instance
            On Error Resume Next
            Set newPowerPoint = GetObject(, "PowerPoint.Application")
            
         
        'Let's create a new PowerPoint
            If Err.Number <> 0 Then
                Set newPowerPoint = CreateObject("PowerPoint.Application")
            End If
            
        'Disable error handling
        On Error GoTo 0
        
        'Show the PowerPoint
            newPowerPoint.Visible = True
            
        'Make a presentation in PowerPoint
            
                newPowerPoint.Presentations.Open ("C:\Users\Default\AppData\Roaming\Microsoft\Templates\blank.potx")

    The problem starts at the underlined line.

    I hope someone know how to solve this.

    Thanks!


    Tuesday, November 8, 2016 2:48 PM

Answers

  • Hi ganeshgebhard,

    >>The Library was missing, but I added the reference. After the that, the error was : Object not found

    How did you add this library? Did you add it directly from Tools->Reference->Available References or Browse the dll from office installation?

    Which line you did you get “Object not found”?

    If you run below piece code in Powerpoint VBA Editor, will you get the same error?

    Sub PowerPointSub1()
         'Look for existing instance
            On Error Resume Next
            Set newPowerPoint = GetObject(, "PowerPoint.Application")
        'Let's create a new PowerPoint
            If Err.Number <> 0 Then
                Set newPowerPoint = CreateObject("PowerPoint.Application")
            End If
        'Disable error handling
        On Error GoTo 0
        'Show the PowerPoint
         newPowerPoint.Visible = True
        'Make a presentation in PowerPoint
         newPowerPoint.Presentations.Open ("C:\Users\Default\AppData\Roaming\Microsoft\Templates\blank.potx")
    End Sub

    If your issue has not been resolved, please feel free to let us know.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ganeshgebhard Friday, November 25, 2016 8:27 AM
    Friday, November 25, 2016 5:17 AM

All replies

  • Hi,

    Do you check if the reference "Microsoft PowerPoint 14.0 Object Library" is missing?

    What is your detail error message? What is your specific version?

    I would suggest you try to repair the Office as a general solution.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 9, 2016 4:45 AM
    Moderator
  • The Library was missing, but I added the reference. After the that, the error was : Object not found
    Wednesday, November 9, 2016 8:44 AM
  • Hi,

    What code are you using now? Which line causes the issue? 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 10, 2016 12:02 PM
    Moderator
  • Thursday, November 10, 2016 12:10 PM
  •  

    If you are using On Error Resume Next, if there is a run time error, it would skip the next sentence and then execute If Err.Number<>0 

    Please visit On Error Statement

    Specifies that when a run-time error occurs, control goes to the statement immediately following the statement where the error occurred where execution continues.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 10, 2016 12:28 PM
    Moderator
  • Hi ganeshgebhard,

    >>The Library was missing, but I added the reference. After the that, the error was : Object not found

    How did you add this library? Did you add it directly from Tools->Reference->Available References or Browse the dll from office installation?

    Which line you did you get “Object not found”?

    If you run below piece code in Powerpoint VBA Editor, will you get the same error?

    Sub PowerPointSub1()
         'Look for existing instance
            On Error Resume Next
            Set newPowerPoint = GetObject(, "PowerPoint.Application")
        'Let's create a new PowerPoint
            If Err.Number <> 0 Then
                Set newPowerPoint = CreateObject("PowerPoint.Application")
            End If
        'Disable error handling
        On Error GoTo 0
        'Show the PowerPoint
         newPowerPoint.Visible = True
        'Make a presentation in PowerPoint
         newPowerPoint.Presentations.Open ("C:\Users\Default\AppData\Roaming\Microsoft\Templates\blank.potx")
    End Sub

    If your issue has not been resolved, please feel free to let us know.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ganeshgebhard Friday, November 25, 2016 8:27 AM
    Friday, November 25, 2016 5:17 AM
  • I added the reference using Tools.

    The code you suggested works!

    Thanks

    Friday, November 25, 2016 8:27 AM