Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

out of range

Status
Not open for further replies.

plusminus

Technical User
Feb 19, 2005
4
0
0
NO
Tell me, please, why: code1 works & code2 doesn't work

code1
Code:
Dim MyArray() As String
Dim n As Byte
______________________________
Private Sub Document_Open()
     ReDim MyArray(10)
End Sub
______________________________
Private Sub txtField_Change()
     n = 0
     MyArray(n) = "No problem"
End Sub

code2(I add a text field at run time)
Code:
Dim MyArray() As String
Dim MyObject As Object
Dim n As Byte
______________________________
Private Sub Document_Open()
     ReDim MyArray(10)
     Set MyObject = ActiveDocument.InlineShapes.AddOLEControl("Forms.TextBox.1")
     MyObject.OLEFormat.Object.Name = "txtField"
End Sub
______________________________
Private Sub txtField_Change()
     n = 0
     MyArray(n) = "Out of range"
End Sub
 
You didn't state it, but is this code to run in VBA under Word?

How did you test case 1 to determine that it works? please indicate the tests you ran that proved it works. I believe either the tests or the testing process need some work.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top