Message 1 of 3
VBA Change Sheet Size

Not applicable
09-27-2012
01:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am having an issue with changing sheet sizes using VBA. Due to the constraints under which my borders and title blocks were created, inventor forces me to delete the current border before changing the sheet size. I have 5 different borders and 2 title blocks.
-Borders
"A0 Border (13x8 Zone)"
"A1 Border (8x6 Zone)"
"A2 Border (6x4 Zone)"
"A3 Border (4x3 Zone)"
"A4 Border (No Zones)"
-Title Blocks
Title Block 1 - All sizes except for A4
Title Block 2 - A4 Only
I have a good idea of what I need to do, but I'm having trouble changing the sheet size. This is the extent of the code that I know actually works:
Thanks for the help!
Option Explicit Private oDoc As DrawingDocument Private oSheet As Sheet Private oBorderDef As BorderDefinition Private oBorder As Border Set oDoc = ThisApplication.ActiveDocument Set oSheet = oDoc.ActiveSheet Set oBorderDef = oDoc.BorderDefinitions.Item("A0 Border (13x8 Zone)") Private Sub UserForm_Initialize() cmbPageSize.AddItem ("A0") cmbPageSize.AddItem ("A1") cmbPageSize.AddItem ("A2") cmbPageSize.AddItem ("A3") cmbPageSize.AddItem ("A4") End Sub Private Sub cmbPageSize_Change() Select Case cmbPageSize.Value Case "A0" MsgBox ("A0") 'Delete Existing Border oSheet.Border.Delete 'Delete Existing Title Block 'Change Sheet Size To A0 'Place Border "A0 Border (13x8 Zone)" 'Place Title Block "1" Case "A1" MsgBox ("A1") 'Delete Existing Border oSheet.Border.Delete 'Delete Existing Title Block 'Change Sheet Size To A1 'Place Border "A1 Border (8x6 Zone)" 'Place Title Block "1" Case "A2" MsgBox ("A2") 'Delete Existing Border oSheet.Border.Delete 'Delete Existing Title Block 'Change Sheet Size To A2 'Place Border "A2 Border (6x4 Zone)" 'Place Title Block "1" Case "A3" MsgBox ("A3") 'Delete Existing Border oSheet.Border.Delete 'Delete Existing Title Block 'Change Sheet Size To A3 'Place Border "A3 Border (4x3 Zone)" 'Place Title Block "1" Case "A4" MsgBox ("A4") 'Delete Existing Border oSheet.Border.Delete 'Delete Existing Title Block 'Change Sheet Size To A4 'Place Border "A4 Border (No Zones)" 'Place Title Block "2" End Select End Sub