Thread: [Solved] Border with random colors
View Single Post
 
Old 09-12-2016, 05:37 AM
VBAbeginner VBAbeginner is offline Windows 10 Office 2016
Novice
 
Join Date: Sep 2016
Posts: 2
VBAbeginner is on a distinguished road
Default Border with random colors

Hey,

I want to create a macro, which automatically creates a random colored border on every single page of the document. Random colors come from a set of 10 or so colors.

I can't manage to find an event for the creation of a new sheet, so this is my alternate plan:

- Button on page 1
- Macro for the button does:

-- Delete all rectangles in document
-- foreach page
--- create rectangle in 0,0 with 5cm width, 29,7cm height
--- set a random color from color set

Is there an easier way than deleting all existing rectangle shapes and adding one to each page?

Can anyone give me a snippet for the rectangle creation with the specific coords and for the creation of the color set and selection of a random color?

Thank you very much!
Reply With Quote