PowerPoint.Row Identifier under cursor is not recognized

pteare

Registered User.
Local time
Today, 08:43
Joined
Sep 24, 2008
Messages
31
Hello,

I'm struggling with some VBA code

Take this line:

Dim new_row As PowerPoint.Row


If I right click on "PowerPoint" and go to "Definition" then it finds it all okay in the object browser (I've included the reference to the Powerpoint 15.0 Library)


If I do the same for "Row" then it gives me this error:

"Identifier under cursor is not recognized"


This seems very strange as when I go to "PowerPoint" in the object browser then "Row" is listed there as a member of "PowerPoint"


Any ideas at all?

I was thinking is the naming ambiguous, but I think PowerPoint is the name of he library - is it possible there's an issue with the naming there?

Thanks!

Phil
 
I don't do any VBA in PowerPoint but it's VBA anyway, so the objects all have similarities or similar patterns.

When does it complain? When you run a code or when you Debug > Complile?
I've just dimmed a variable as the above and it compiled fine.
 
Hello,

Thanks for the reply.

It compiles all okay both ways.

Issue comes when the code runs later on:

e.g.
Dim new_row As PowerPoint.Row

new_row.Cells(1).shape.TextFrame.TextRange = "something"


It will give me an error -

-2147417851 : Method 'Text' of object 'TextRange' failed


Please note this error only comes up on access 2013. It runs fine on access 2010.

It's not consistent though - sometimes it works, sometimes not.

So I've been working back up and found it couldn't find PowerPoint.Row, and wondered if that was the source of the issue?

Thanks!

Phil.
 
Are you running the code from PP?
Also, try postfixing TextRange with .Text
 
Thanks for that.

I'm running the code from within Access 2013

I tried putting .Text on the end of that line - that made it work just once, and 2nd time I tried to run it the error came back again.
 
Thanks for the reply. That would be wonderful if you could look over it and amend, thanks.

Here's the code:

Code:
Private Sub AddRowInFilterTable(current_table As PowerPoint.Table, current_category As Integer)
    Dim new_row As PowerPoint.Row
    Dim str_cat As String
    
    On Error GoTo err_table
    
    ' If just 2 lines in the table with empty cell (don't add a new row, just use the existing one)
    If current_table.Rows.Count = 2 And current_table.Rows(2).Cells(1).shape.TextFrame.TextRange = "" Then
        Set new_row = current_table.Rows(2)
    Else
        Set new_row = current_table.Rows.add    ' Add a new row
    End If

    str_cat = format(current_category, "00")

    With new_row
        ' 1st Column: Category number (@CATEGORYXX@)
        .Cells(1).shape.TextFrame.TextRange = "@CATEGORY" & str_cat & "@"

        ' 2nd Column: Total Contacted (@CATXX_TOTAL_CONTACTED@)
        .Cells(2).shape.TextFrame.TextRange = "@CAT" & str_cat & "_TOTAL_CONTACTED@"

        ' 3rd Column: Total Completed (@CATXX_TOTAL_RESPONSES@)
        .Cells(3).shape.TextFrame.TextRange = "@CAT" & str_cat & "_TOTAL_RESPONSES@"

        ' 4th Column: Rate (@CATXX_RESPONSE_RATE@%)
        .Cells(4).shape.TextFrame.TextRange = "@CAT" & str_cat & "_RESPONSE_RATE@%"

        ' If table for Account Manager (4 columns more)
        If current_table.Columns.Count > 4 Then
            ' 5th Column: Total Account Contacted(@CATXX_TOTAL_COMPANY_CONTACTED@)
            .Cells(5).shape.TextFrame.TextRange = "@CAT" & str_cat & "_TOTAL_COMPANY_CONTACTED@"
            ' 6th Column: Total Account responses (@CATXX_TOTAL_COMPANY_RESPONSE@)
            .Cells(6).shape.TextFrame.TextRange = "@CAT" & str_cat & "_TOTAL_COMPANY_RESPONSE@"
            ' 7th Column: Total Account Rate(@CATXX_COMPANY_RESPONSE_RATE@)
            .Cells(7).shape.TextFrame.TextRange = "@CAT" & str_cat & "_COMPANY_RESPONSE_RATE@%"
        End If
    End With
    
    Exit Sub
err_table:
    DisplayError "AddRowInFilterTable"
End Sub

Thanks again for your help.
 
I thought I was going to see something obvious.

How did you create the table from before? Can you upload the file?
 
Hello,

thanks for that. I can't upload the file sorry, this database belongs to a client you see. I didn't build it, just trying to de-bug, fun fun!


There's a powerpoint template it uses - it just looks at the slides on this template file then finds the table it needs. This happens in a different sub:


Code:
Set filter_table = current_slide.Shapes(FILTER_TABLE_SHAPE_NAME & TablePostFix).Table

That is reassuring that you didn't see anything wrong with the code in the last post. Just to re-iterate - this all works on Access & Powerpoint 2010, only 2013 throws the error.
 
I don't need the entire db, just the code that uses PP and any PP template file.

Also try declaring new_row as Object or Variant.
 
Another thing as well, how did you declare the PP object?
 
Hello,


I tried declaring new_row as object and as variant, still the same error persists.

The PowerPoint objects are declared as Global Variables:

Code:
Public oPPTApp As PowerPoint.Application
Public oPPTPres As PowerPoint.Presentation

then the below code opens the powerpoint template & creates a copy of it to be used:

Code:
    If PowerPointFilename <> "" Then
        Set oPPTApp = CreateObject("PowerPoint.Application")
        If Not oPPTApp Is Nothing Then
            With oPPTApp
                Set oPPTPres = .Presentations.Open(template_file_name, , , False)
                If oPPTPres Is Nothing Then GoTo err_open
                oPPTPres.SaveAs CurrentProject.Path & "\" & report_file_name & ".pptm"
                ' Check the template file for the return value
                OpenPowerPoint = CheckTemplate(report_file_name)
            End With
        Else
            MsgBox "Unable to launch PowerPoint! Please try to restart manually Power Point or your computer", vbCritical, "PowerPoint Automation"
        End If
    Else
        MsgBox "Select a PowerPoint template file first.", vbExclamation
    End If


I'll need to do some work to cut out the bits of the database needed for PowerPoint for you. Will also need to talk to the client as well so we'll see before I can do that, so might be a bit.

Thanks again for all your help.
 
One more thing to try is late-binding, so change these two lines:
Code:
Public oPPTApp As [COLOR="Blue"]Object[/COLOR]
Public oPPTPres As [COLOR="blue"]Object[/COLOR]
It may not seem much but it does help in some cases.
 
thanks for that. Alas no luck!

This is a strange one with it being inconsistent. There are lots of places it sets the Text value of the TextRange. Sometimes the first one fails, sometimes a few succeed then it fails, and very occasionally it runs all the way through successfully.
 
It's 2013 that's causing the issue (not sure if that was just a typo)

Yes I've tried it on 3 machines running 2013, all have the same issue.
 
Considering I deal with hundreds of other people, expect these sort of mistakes ;)

There should be other ways of creating that Text but I'll need to see the full code and a PP template.
 
By the way, are you able to set other properties of TextRange like Size, Color without any hiccups?
 

Users who are viewing this thread

Back
Top Bottom