Use a parameter with item

Use a parameter with item

TONELLAL
Collaborator Collaborator
365 Views
2 Replies
Message 1 of 3

Use a parameter with item

TONELLAL
Collaborator
Collaborator

Hello,

I have a problem with using a parameter as item("xxx") :

 

Dim oPart as PartDocument

Dim oRenderstyle as Renderstyle

Dim toto as String

 

'This is ok :

Set oRenderstyle = oPart.RenderStyles.item("Red")

 

'This is NOT ok :

toto = "Red"

Set oRenderstyle = oPart.RenderStyles.item(toto)

 

 

Could you tell me where is the problem ? Thanks !

0 Likes
366 Views
2 Replies
Replies (2)
Message 2 of 3

wayne.brill
Collaborator
Collaborator

Hi,

 

I am not recreating this so far. Below is the VBA code I used. Is there an error?

 

Sub string_param_test()
    Dim oPart As PartDocument
    Dim oRenderstyle As RenderStyle
    Dim toto As String
    
    Set oPart = ThisApplication.ActiveDocument
    
    'This is ok :
    Set oRenderstyle = oPart.RenderStyles.Item("Red")
     
     'this is ok too
     toto = "Red"
     Set oRenderstyle = oPart.RenderStyles.Item(toto)

End Sub

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

TONELLAL
Collaborator
Collaborator
Effectively, on the first test "toto" was only defined by "dim toto". When specifying "dim toto as string" it is ok !
0 Likes