CAD/CAM discussion forum > CAD > VBA: GetCanonicalMediaNames

VBA: GetCanonicalMediaNames

    
  Subscribe Topic

Rank: 1

Hrvoje Krnić

Newbie

posts: 0

Registered: 2010-7-15

Message 1 of 3

02-04-2010 06:58 . pm   |   View his/her posts only
Hi.
I start writing Zwcad VBA macro where I want set layout paper size. I try list all plot devices and their available media in form with two combobox.
This is my code in initialization of form:
For i = 1 To Bound(ThisDocument.PaperSpace.Layout.GetPlotDeviceNames)
PName = ThisDocument.PaperSpace.Layout.GetPlotDeviceNames(i)
cbPlotDevice.AddItem PName
Next
cbPlotDevice.ListIndex = 0

Setting ComboBox ListIndex property call combobox event Change where I put data about media in second combobox:

Private Sub cbPlotDevice_Change()
Dim i As Integer
Dim default As Integer
Dim PName As String
ThisDocument.PaperSpace.Layout.ConfigName = cbPlotDevice.Text
ThisDocument.PaperSpace.Layout.RefreshPlotDeviceInfo
cbPlotPaperMedia.Clear
default = 0
For i = 0 To UBound(ThisDocument.PaperSpace.Layout.GetCanonicalMediaNames)
PName = ThisDocument.PaperSpace.Layout.GetCanonicalMediaNames(i)
cbPlotPaperMedia.AddItem PName
Next
cbPlotPaperMedia.ListIndex = 0
End Sub

When program try execute GetCanonicalMediaNames I got error "Type Mismatch" because GetCanonicalMediaNames property is Empty. Similar example I found in ZWcad help but I got same error. What is wrong? How I can get list of media for specificied plot device?

Rank: 1

Hrvoje Krnić

Newbie

posts: 0

Registered: 2010-7-15

Message 2 of 3

06-04-2010 03:09 . pm   |   View his/her posts only
After while searching I found solution.
First I created my new layout and than replace ThisDocument.PaperSpace.Layout with reference to new layout.
Now, everything work fine.

Thanks

Rank: 1

OldForumPost

Newbie

posts: 0

Registered: 2012-1-14

Message 3 of 3

07-04-2010 02:15 . pm   |   View his/her posts only
thank you for your sharing. actually, i am not good at VBA programming. Hope to learn more from you. Smile
See also
X