swetha
swetha

Reputation: 39

run time error '-2147024809(80070057)' the specified value is out of range

Im trying to format a text box present in a slide in a PPT using VBA ;by taking the input values for properties of text box like font name,alignment etc from an Excel file.

Select Case Shp_new.Type
              
         Case MsoShapeType.msoTextBox      
            Shp_new.TextFrame.TextRange.Font.Name = "" & textboxrange.Cells(1, 1).Value & ""
            Shp_new.TextFrame.TextRange.ParagraphFormat.Alignment = textboxrange.Cells(1, 4).Value 

End Select                                                                                   

But,it is throwing me the following error "run time error '-2147024809(80070057)' the specified value is out of range" for text alignment property and moreover only when the value for text alignment is '-2'.

The Text alignment values that I have in my input excel file are as follows : 0,1,2,3,4,-2 these values in Excel file are generated by the following piece of code

Shp_new.TextFrame.TextRange.ParagraphFormat.Alignment

From the following post https://learn.microsoft.com/en-us/office/vba/api/access.textbox.textalign I was able to understand the type of alignment for the values: 0,1,2,3,4 But as per the doc, there is no such alignment type '-2' . Not sure why it is giving me -2 value for few text boxes.

I feel that since there is no such alignment type -2 , it is throwing me an error.

But not sure what exactly is the cause of this error.Needed help in this regard

Upvotes: 1

Views: 728

Answers (1)

Variatus
Variatus

Reputation: 14383

"Mixed" alignment isn't a particularly clear instruction. It takes its meaning from the installed language. In other words, if you work in a language where the instruction makes sense you can use it. Reverse-engineered, if it doesn't work for you it doesn't make sense in the language in which you work.

Click here to refer to Microsoft's explanation, the short of which I copy for you below.

"Some of the constants listed above may not be available to you, depending on the language support (U.S. English, for example) that you’ve selected or installed."

Upvotes: 1

Related Questions