#1




Splict funtction parts retrieval
I need to know how to increment the parts of a SPLIT FUNCTION within a for each loop
Code:
i = 0 If optBoth Then For Each exp In Split(s, ",") Set nameShp = ActiveLayer.FindShape("name") nameShp.Text.Story = exp(i) i = i + 1 Set numShp = ActiveLayer.FindShape("number") numShp.Text.Story = exp(i) i = i + 1 Set sr = d.ActiveLayer.Shapes.All Set MyPage = ActiveDocument.InsertPages(1, False, ActivePage.Index) sr.CopyToLayer MyPage.ActiveLayer Next exp End If (i.e. WARING,6,TINSLEY,16,RAINES,7,MARTEL,18,MARKS,9,KARRER,17,HUNTEBRINKER,5,HUNTEBRINKER,21,GREENWELL,11,FORBES,2,FELTS,12,AUTRY,32) I want nameShp.text.story to equal the first part of "s", then numShp.text.story to equal the next part and so on through the loop.
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. 
#2




Split
This will be easier if you use a For Next loop. Also you need to remove one of the i = i + 1 as the loop will advance itself. So something like this should work:
Code:
Dim exp As Variant exp = Split(s, ",") For i = 0 To UBound(exp) Set nameShp = ActiveLayer.FindShape("name") nameShp.Text.Story = exp(i) i = i + 1 Set numShp = ActiveLayer.FindShape("number") numShp.Text.Story = exp(i) Set sr = d.ActiveLayer.Shapes.All Set MyPage = ActiveDocument.InsertPages(1, False, ActivePage.Index) sr.CopyToLayer MyPage.ActiveLayer Next i Shelby 
#3




Code:
Dim exp As Variant exp = Split(s, ",") For i = 0 To UBound(exp) Set nameShp = ActiveLayer.FindShape("name") nameShp.Text.Story = exp(i) nameShp.OrderToFront i = i + 1 Set numShp = ActiveLayer.FindShape("number") numShp.Text.Story = exp(i) numShp.OrderToFront 'if exp is empty then Exit For Set sr = d.ActiveLayer.Shapes.All Set MyPage = ActiveDocument.InsertPages(1, False, ActivePage.Index) sr.CopyToLayer MyPage.ActiveLayer Next i Never mind. I answered my own question by adding watches to certain variables and came up with this... Code:
If optBoth Then exp = Split(s, ",") For i = 0 To UBound(exp) Set nameShp = ActiveLayer.FindShape("name") nameShp.Text.Story = exp(i) nameShp.OrderToFront i = i + 1 Set numShp = ActiveLayer.FindShape("number") numShp.Text.Story = exp(i) numShp.OrderToFront If i = UBound(exp) Then Exit For Set sr = d.ActiveLayer.Shapes.All Set MyPage = ActiveDocument.InsertPages(1, False, ActivePage.Index) sr.CopyToLayer MyPage.ActiveLayer Next i End If
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. Last edited by ddonnahoe; 06042012 at 07:42. 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)  
Thread Tools  Search this Thread 
Display Modes  

