Thanks for your suggestions Tony. I solved the problem with the following
code :
Dim mediaNames As Variant
Dim name As String
Dim siz as String
siz = "my_custom_paper_size"
mediaNames = layout.GetCanonicalMediaNames()
For x = LBound(mediaNames) To UBound(mediaNames)
name = layout.GetLocaleMediaName(mediaNames(x))
If InStr(1, name, siz, vbTextCompare) = 1 Then
layout.CanonicalMediaName = mediaNames(x)
layout.RefreshPlotDeviceInfo
GoTo fine_ciclo
End If
Next
fine_ciclo:
this way the 80200003 error disappeared. It seems that the descriptions you
see in the paper size list of the plotter are not stored with that name. One
have to translate via the GetLocaleMediaName function the paper sizes
returned from GetCanonicalMediaNames. Now it works !
"Tony Burba" wrote in message
news:5102472@discussion.autodesk.com...
The actual canonical media name for a paper size is usually not simply the
paper size. You need to use the GetCanonicalMediaNames method to get all the
available valid media names for a given plotter.
Below is a function that creates an Excel spreadsheet listing all the
canonical media names for all your installed plotters and printers. Perhaps
it will help.
Public Sub tl_showplotsizes()
Dim oldplotter As String
Dim layout As AcadLayout
Dim plottername As String
Dim plotters As Variant
Dim plotsizes As Variant
Dim rownum As Integer, cnt As Integer
Dim Excel As Object
Dim excelsheet As Object
Dim excelbook As Object
Set layout = ActiveDocument.ActiveLayout
oldplotter = layout.configname
plotters = layout.GetPlotDeviceNames
Dim plotter As Variant
On Error Resume Next
Set Excel = GetObject(, "Excel.Application")
If Err <> 0 Then
Err.Clear
Set Excel = CreateObject("Excel.Application")
If Err <> 0 Then
MsgBox "Could not start Excel.", vbExclamation
Exit Sub
End If
End If
' On Error GoTo 0
With Excel
.Visible = True
.Workbooks.Add
End With
Set excelbook = Excel.ActiveWorkbook
Set excelsheet = excelbook.ActiveSheet
rownum = 1
With excelsheet
.Unprotect
.Columns("A").ColumnWidth = 5
For Each plotter In plotters
On Error Resume Next
layout.configname = plotter
If Err.number = 0 Then
.Cells(rownum, 1) = "Plot size names for " & UCase(plotter)
rownum = rownum + 1
plotsizes = layout.GetCanonicalMediaNames
For cnt = 0 To UBound(plotsizes)
.Cells(rownum, 2) = plotsizes(cnt)
rownum = rownum + 1
Next cnt
.Cells(rownum, 1) = ""
rownum = rownum + 1
Else
Err.Clear
End If
Next plotter
.Columns("B").AutoFit
.Protect
End With
Set excelsheet = Nothing
Set excelbook = Nothing
layout.configname = oldplotter
End Sub
"kombian" wrote in message
news:5102204@discussion.autodesk.com...
Hi all ! I read on the VBA doc that to set the paper size from code one have
to use the CanonicalMediaName property of the Plotconfiguration or Layout
object. I use the following code where siz is a string variabile that
contains one of the paper sizes of the plotter.
layout.CanonicalMediaName = siz
I always get a 80200003 error with the description "invalid entry". I'm
wondering what is wrong. the doc states that the CanonicalMediaName
property is a read/write one. I'm able to read it without any problem but
how to write it ? Just for information... the paper size I'm tryng to set is
a custom size and as a String I use the name I gave to the custome size when
I defined. Is there some hidden name to use ? My custom size when accessed
via the GetLocaleMediaName function give me a UserDefineMetric (something
here..) string. I tried this too but it didn't work. Is there someone that
knows the meaning og the 80200003 error code ?
Sandro