Share via

Run-time error '5152'

Anonymous
2019-04-24T00:46:20+00:00

I have zero background in Macros but I need to use it in my new job sometimes. There was a saved file which I just need to run but I always keep getting Run-time error '5152'.

Here's the part where it shows error (red font):

 If Sheet3.Cells(ExcelRowCounter, ElementType).Value = "Sub-Process" Then

        With ObjWord

        .Selection.Font.Name = "Trebuchet MS"

        .Selection.Font.Size = 10

        .Selection.Range.SetListLevel Level:=5

        .Selection.TypeParagraph

        Call addimage(urlpathfilename, usedapplicaiton)

        .Selection.InlineShapes.AddPicture Filename:=urlpathfilename, LinkToFile:=False, SaveWithDocument:=True

        .Selection.Range.SetListLevel Level:=1

        .Selection.TypeText Text:=Sheet3.Cells(ExcelRowCounter, 2).Value

        .Selection.TypeParagraph

        End With

            If Sheet3.Cells(ExcelRowCounter, 27).Value <> "" Then

                For RomanNumeralCounter = 27 To 46

                    If Sheet3.Cells(ExcelRowCounter, RomanNumeralCounter).Value <> "" Then

                        With ObjWord

                            .Selection.Font.Name = "Trebuchet MS"

                            .Selection.Font.Size = 10

                            .Selection.Range.SetListLevel Level:=3

                            .Selection.TypeText Text:=Sheet3.Cells(ExcelRowCounter, RomanNumeralCounter).Value

                            .Selection.TypeParagraph

                        End With

                    End If

                Next RomanNumeralCounter

            End If

Any thoughts on what should I do? Help.

Thank you.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323K Reputation points MVP Volunteer Moderator
    2019-04-25T05:51:47+00:00

    You have not given any information about the code in addimage(urlpathfilename, usedapplicaiton) and there is a possibility that there is a spelling error in the second argument (usedapplicaiton)

    If you put a 

    Msgbox urlpathfilename in your code, what does it display?

    Was this answer helpful?

    0 comments No comments