Jump to content

Trying to finish up my VBA page layout macro


Recommended Posts

Posted

Can someone please look this over and tell me where my errors are? I seem to have two of them and I just can't figure them out.

 

1. Down at my "CopyFrom" lines....The program seems to go through the process but it still sends me to error control

2. No matter how I set my plot rotation, the plot preview window still retains "portrait" when I need it to switch to "landscape".

 

 
Option Explicit
Public Sub CreatePageSetup()
On Error GoTo GetErr
'MsgBox "                                        BE PATIENT" & vbCr & vbCr & "THE PAGE LAYOUT SETUP CAN TAKE UP TO 30 SECONDS"
GoGetCanonicalMediaNames
Dim pLayoutConfig As AcadLayout
Set pLayoutConfig = ThisDrawing.ActiveLayout
Dim MyPlotSize As String
MyPlotSize = "User2314" '<---------------- Use PlotPaperSizeNames.dvb to ascertain this value
Dim PaperSpaceLayout As AcadLayout
Dim ModelSpaceLayout As AcadLayout
Dim pPlotConfigs As AcadPlotConfigurations
Set pPlotConfigs = ThisDrawing.PlotConfigurations
Dim pPlotConfig As AcadPlotConfiguration
Set pPlotConfig = pPlotConfigs.Add("SCI 24x36", False)
   With pPlotConfig
       pLayoutConfig.RefreshPlotDeviceInfo
       pLayoutConfig.ShowPlotStyles = False
       pLayoutConfig.ConfigName = "My Plotter"
       pLayoutConfig.StyleSheet = "My CTB"
       pLayoutConfig.CanonicalMediaName = MyPlotSize
       pLayoutConfig.PlotType = acExtents
       pLayoutConfig.CenterPlot = True
       pLayoutConfig.StandardScale = ac1_1
       pLayoutConfig.PaperUnits = acInches
       pLayoutConfig.PlotWithPlotStyles = True
       pLayoutConfig.PlotViewportsFirst = True
       pLayoutConfig.PlotRotation = ac90degrees
       pLayoutConfig.RefreshPlotDeviceInfo
   End With

Set ModelSpaceLayout = ThisDrawing.ModelSpace.Layout
ModelSpaceLayout.CopyFrom pPlotConfig
Set PaperSpaceLayout = ThisDrawing.PaperSpace.Layout
PaperSpaceLayout.CopyFrom pPlotConfig
ThisDrawing.Regen acAllViewports
GetErr:
If Err.Number <> 0 Then MsgBox ("UNIDENTIFIED ERROR")
MsgBox "            DONE"
End Sub
Private Sub GoGetCanonicalMediaNames()
Dim PaperSize As String
Dim MediaNames As Variant
Dim i As Integer
MediaNames = ThisDrawing.ActiveLayout.GetCanonicalMediaNames
For i = LBound(MediaNames) To UBound(MediaNames)
If StrComp(ThisDrawing.ActiveLayout.GetLocaleMediaName(MediaNames(i)), PaperSize, vbTextCompare) = 0 Then
ThisDrawing.ActiveLayout.CanonicalMediaName = MediaNames(i)
ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo
End If
Next
'MsgBox i
End Sub

 

Can anyone give me a hand figuring this out?

 

Thank you

Mike

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...