+ Reply to Thread
Results 1 to 1 of 1

Drawing Rectangles

  1. #1
    Registered User
    Join Date
    11-06-2011
    Location
    Surrey
    MS-Off Ver
    Excel 2010
    Posts
    51

    Drawing Rectangles

    Guys

    I use the following loop to draw 4 lines to draw a rectangle and reiterate it 19 times

    Dim img As Object
    Dim a, B, C, D, E
    B = 0
    C = 4
    E = 1
    For a = 1 To 19
    B = B + 20
    Set img = ActiveSheet.Pictures.Insert("C:\Users\Mark\Desktop\App Pics\" & Worksheets("Sheet2").Range("H" & a).Value)
    Sheet1.Shapes.AddTextbox(msoTextOrientationHorizontal, 350, B, 300, 200).TextFrame.Characters.Text = Worksheets("Sheet2").Range("A" & a).Value & vbNewLine & Worksheets("Sheet2").Range("B" & a).Value & vbNewLine & Worksheets("Sheet2").Range("C" & a).Value & vbNewLine & Worksheets("Sheet2").Range("D" & a).Value & vbNewLine & Worksheets("Sheet2").Range("E" & a).Value & vbNewLine & Worksheets("Sheet2").Range("F" & a).Value & vbNewLine & Worksheets("Sheet2").Range("G" & a).Value & vbNewLine & Worksheets("Sheet2").Range("H" & a).Value
    img.Left = 75
    img.Top = B
    img.Width = 300
    img.Height = 200
    ActiveWorkbook.ActiveSheet.Shapes.AddLine(65, B - 40, 660, B - 40).Line.DashStyle = msoLineSolid
    ActiveWorkbook.ActiveSheet.Shapes.AddLine(65, B - 40, 65, B - 260).Line.DashStyle = msoLineSolid
    ActiveWorkbook.ActiveSheet.Shapes.AddLine(65, B - 260, 660, B - 260).Line.DashStyle = msoLineSolid
    ActiveWorkbook.ActiveSheet.Shapes.AddLine(660, B - 260, 660, B - 40).Line.DashStyle = msoLineSolid

    B = B + 230
    C = C + 17
    Next a
    B = B + 20

    Problem I have it is perfect except the first rectangle the two side lines are done twice and off center so when I delete them the rectangle is perfect underneath

    Any ideas whats wrong with the code I cant work out whats wrong it only prints 4 lines 19 times but I find it odd that the forist one is printed twice

    Any help appreciated

    Mark


    UPDATE

    IGNORE ME GUYS FOUND A WAY ROUNDTHIS

    Dim img As Object
    Dim a, B
    B = 0
    For a = 1 To 19
    B = B + 20
    Set img = ActiveSheet.Pictures.Insert("C:\Users\Mark\Desktop\App Pics\" & Worksheets("Sheet2").Range("H" & a).Value)
    img.Left = 75
    img.Top = B
    img.Width = 300
    img.Height = 200
    Sheet1.Shapes.AddTextbox(msoTextOrientationHorizontal, 350, B, 300, 200).TextFrame.Characters.Text = Worksheets("Sheet2").Range("A" & a).Value & vbNewLine & Worksheets("Sheet2").Range("B" & a).Value & vbNewLine & Worksheets("Sheet2").Range("C" & a).Value & vbNewLine & Worksheets("Sheet2").Range("D" & a).Value & vbNewLine & Worksheets("Sheet2").Range("E" & a).Value & vbNewLine & Worksheets("Sheet2").Range("F" & a).Value & vbNewLine & Worksheets("Sheet2").Range("G" & a).Value & vbNewLine & Worksheets("Sheet2").Range("H" & a).Value
    ActiveSheet.Shapes.AddShape _
    (msoShapeFlowchartProcess, 65, B - 10, 600, 220).Select
    Selection.ShapeRange.Fill.ForeColor.SchemeColor = 11
    Selection.ShapeRange.Fill.Solid
    Selection.ShapeRange.Fill.Visible = msoFalse
    B = B + 230

    Next a
    Last edited by wambaugh; 06-09-2015 at 12:42 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Cant click into cells - drawing rectangles appear !!
    By hchadwick in forum Excel General
    Replies: 3
    Last Post: 05-21-2014, 12:18 PM
  2. [SOLVED] Drawing rectangles from x-y pairs in a table
    By MAA in forum Excel General
    Replies: 2
    Last Post: 04-19-2012, 07:24 PM
  3. Rectangles, 1000's of them in spreadsheet.
    By okanem in forum Excel General
    Replies: 1
    Last Post: 06-20-2007, 06:12 AM
  4. [SOLVED] loop through rectangles on worksheet
    By jeichhold via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2006, 09:45 AM
  5. [SOLVED] Clearing rectangles
    By Andrew B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-05-2006, 07:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1