Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-13-2016, 04:22 AM
Guessed's Avatar
Guessed Guessed is offline Border with random colors Windows 10 Border with random colors Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I would use a way of tagging each of the border shapes when I put them in. That way it is much easier to identify the borders and kill them off. The normal (cheats ) way I go about tagging a shape is to use its alternative text property and hope that none of your other shapes has used the same thing. An example of doing it this way is...
Code:
Sub AddRandomBorder()
  Dim aRng As Range, i As Integer, aPara As Paragraph, aShp As Shape
  Dim iWidth As Integer, iHeight As Integer
  
  With ActiveDocument.Sections(1).PageSetup
    iWidth = .PageWidth - 40
    iHeight = .PageHeight - 40
  End With
  'Get rid of the existing borders
  For i = ActiveDocument.Shapes.Count To 1 Step -1
    If ActiveDocument.Shapes(i).AlternativeText = "Page Border" Then ActiveDocument.Shapes(i).Delete
  Next i
  
  For Each aPara In ActiveDocument.Paragraphs
    Set aRng = aPara.Range
    aRng.Collapse Direction:=wdCollapseStart
    If aRng.Information(wdActiveEndPageNumber) > i Then
      Set aShp = ActiveDocument.Shapes.AddShape(Type:=1, Left:=20, Top:=20, _
              Width:=iWidth, Height:=iHeight, Anchor:=aRng)
      With aShp
        .AlternativeText = "Page Border"
        .Line.ForeColor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
        .Line.Weight = 3
        .Fill.Transparency = 1
      End With
      i = aRng.Information(wdActiveEndPageNumber)
    End If
  Next aPara
End Sub

__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Border with random colors Aligning Page Border with Table border without losing formatting :mad: l39linden Word Tables 5 10-04-2013 02:06 AM
Border with random colors Bar colors ketanco Project 1 03-30-2013 08:24 AM
Border with random colors Unable to change font colors from theme colors choy Word 3 08-01-2012 09:12 PM
random pop up wont go away 464646 OneNote 0 05-01-2012 04:34 AM
Only Random Border Lines Printing! TheCatSpeaks Excel 4 05-17-2010 07:39 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft