How do I make a macro that will make a table with random numbers in it based of user's two inputs?
I know how to do console vb programming with user input and all just cant figure out how to get it to work in corel
Below you can find code that creates grid 5x5 of random numbers between two entered values
Sub GridOfNumbers2() Dim s1 As Shape, startnum As Integer, endnum As Integer, i As Integer, ix As Integer Dim ti Randomize ActiveDocument.Unit = cdrMillimeter ActiveDocument.BeginCommandGroup ("numbers") startnum = InputBox("Enter 1. number") endnum = InputBox("Enter 2. number") Optimization = True ti = Int(startnum + (startnum * Rnd)) For i = startnum To (startnum + 4) For ix = startnum To (startnum + 4) Set s1 = ActiveLayer.CreateArtisticText(0 + x, 290 + y, Format(ti, "000")) s1.Fill.UniformColor.CMYKAssign 0, 0, 0, 100 s1.Outline.SetNoOutline x = x + 20 ti = Int(startnum + ((endnum - startnum) * Rnd)) Next ix x = 0 y = y - 20 Next i ActiveDocument.BeginCommandGroup ("numbers") Optimization = False ActiveWindow.RefreshEnd Sub
This is what I have so far but how can I generate twice on multiple pages in same document based on user entry.
Sub GridOfNumbers2() Dim s1 As Shape, startnum As Integer, endnum As Integer, i As Integer, ix As Integer Dim ti Randomize ActiveDocument.Unit = cdrMillimeter startnum = InputBox("Enter 1. number") endnum = InputBox("Enter 2. number") Optimization = True ti = Int(startnum + (startnum * Rnd)) For i = startnum To (startnum + 4) For ix = startnum To (startnum + 4) Set s1 = ActiveLayer.CreateArtisticText(0 + x, 290 + y, Format(ti, "00")) s1.Fill.UniformColor.CMYKAssign 0, 0, 0, 100 s1.Outline.SetNoOutline x = x + 20 ti = Int(startnum + ((endnum - startnum) * Rnd)) Next ix x = 0 y = y - 20 Next i ActiveDocument.BeginCommandGroup ("numbers") Optimization = False ActiveWindow.Refresh ActiveDocument.ReferencePoint = cdrCenter ActiveDocument.CreateSelection ActiveLayer.Shapes(25), ActiveLayer.Shapes(24), ActiveLayer.Shapes(23), ActiveLayer.Shapes(22), ActiveLayer.Shapes(21), ActiveLayer.Shapes(20), ActiveLayer.Shapes(19), ActiveLayer.Shapes(18), ActiveLayer.Shapes(17), ActiveLayer.Shapes(16), ActiveLayer.Shapes(15), ActiveLayer.Shapes(14) ActiveDocument.AddToSelection ActiveLayer.Shapes(13), ActiveLayer.Shapes(12), ActiveLayer.Shapes(11), ActiveLayer.Shapes(10), ActiveLayer.Shapes(9), ActiveLayer.Shapes(8), ActiveLayer.Shapes(7), ActiveLayer.Shapes(6), ActiveLayer.Shapes(5), ActiveLayer.Shapes(4), ActiveLayer.Shapes(3) ActiveDocument.AddToSelection ActiveLayer.Shapes(2), ActiveLayer.Shapes(1) Set s1 = ActiveSelection.Group ActiveSelection.Group.SetSize 144.3481, 109.3469 ActiveSelection.Group.SetPosition 137.2107, 135.5852End Sub
Sub GridOfNumbers3() Dim s1 As Shape, startnum As Integer, endnum As Integer, i As Integer, ix As Integer, npages As Integer, ip As Integer Dim ti Randomize ActiveDocument.Unit = cdrMillimeter ActiveDocument.BeginCommandGroup ("numbers") npages = InputBox("Enter number o pages") For ip = 0 To npages - 1 startnum = InputBox("Enter 1. number for page no. " & (ip + 1)) endnum = InputBox("Enter 2. number for page no. " & (ip + 1)) ti = Int(startnum + (startnum * Rnd)) For i = startnum To (startnum + 4) For ix = startnum To (startnum + 4) Set s1 = ActiveLayer.CreateArtisticText(0 + x, 290 + y, Format(ti, "00")) s1.Fill.UniformColor.CMYKAssign 0, 0, 0, 100 s1.Outline.SetNoOutline x = x + 20 ti = Int(startnum + ((endnum - startnum) * Rnd)) Next ix x = 0 y = y - 20 Next i ActiveDocument.ReferencePoint = cdrCenter ActivePage.FindShapes(Type:=cdrTextShape).AddToSelection Set s1 = ActiveSelection.Group s1.SetSize 144.3481, 109.3469 s1.SetPosition 137.2107, 135.5852 ActiveDocument.AddPages (1) Pages(ip + 2).Activate x = 0 y = 0 Next ip Pages(ip + 1).Delete Pages(1).Activate ActiveDocument.EndCommandGroup ActiveWindow.Refresh End Sub