R
Ryan Jamison
Hi All,
I am having great difficulty in trouble shooting a macro (below is a
shortened version, but with same functionality):
Sub Macro1()
Dim myArray(0 To 1, 0 To 1) As String
Dim i As Long, prange As String, srange As Range
Dim strNum As String
myArray(0, 0) = "Alum"
myArray(1, 0) = "Steel"
myArray(0, 1) = "1"
myArray(1, 1) = "2"
With ActiveDocument
For i = 1 To .Paragraphs.Count
prange = ActiveDocument.Paragraphs(i).Range.Text
If Left(prange, 10) = "MATERIAL " Then
strNum = Mid(prange, 11)
End If
Next i
End With
MsgBox strNum & myArray(1, 1)
If strNum = myArray(1, 1) Then
MsgBox "TRUE"
End If
End Sub
The active document looks like:
MATERIAL 1
// from 'MAT1 1 '
Isotropic
E=1e+07
NU=0.3
density=0.00025382
END
MATERIAL 2
// from 'MAT1 2 '
Isotropic
E=6e+07
NU=0.3
density=0.0.003
END
I'm having difficulty with the "IF" statement at the very end. The results
of the MsgBox look the same, but evaluate differently. Any ideas?
Ryan
I am having great difficulty in trouble shooting a macro (below is a
shortened version, but with same functionality):
Sub Macro1()
Dim myArray(0 To 1, 0 To 1) As String
Dim i As Long, prange As String, srange As Range
Dim strNum As String
myArray(0, 0) = "Alum"
myArray(1, 0) = "Steel"
myArray(0, 1) = "1"
myArray(1, 1) = "2"
With ActiveDocument
For i = 1 To .Paragraphs.Count
prange = ActiveDocument.Paragraphs(i).Range.Text
If Left(prange, 10) = "MATERIAL " Then
strNum = Mid(prange, 11)
End If
Next i
End With
MsgBox strNum & myArray(1, 1)
If strNum = myArray(1, 1) Then
MsgBox "TRUE"
End If
End Sub
The active document looks like:
MATERIAL 1
// from 'MAT1 1 '
Isotropic
E=1e+07
NU=0.3
density=0.00025382
END
MATERIAL 2
// from 'MAT1 2 '
Isotropic
E=6e+07
NU=0.3
density=0.0.003
END
I'm having difficulty with the "IF" statement at the very end. The results
of the MsgBox look the same, but evaluate differently. Any ideas?
Ryan