Type mismatch error
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Type mismatch error

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
doug k
Guest





Posted: Wed Mar 16, 2005 6:21 pm    Post subject: Type mismatch error Reply with quote

Laurie Comerford and all,

This routine supplied by Laurie looks like it would do exactly what I want,
however it will not run for me.

I'm getting a compile error: type mismatch on the line:
"ThisDrawing.ActiveLayer = sLayerName"
but from what i've read in help, this should have been ok (I'm rookie-rank)

Here is the routine provided earlier. I changed the colorcode to be
compatible with 2005 (I hope) and deleted a layer lineweight setting.

Sub CreateTextLayer()
On Error Resume Next
Dim sLayerName As String
Dim oLayer As AcadLayer
Dim oEnt As AcadEntity
Dim Pt(0 To 2) As Double
Dim sNameExtension As String
sNameExtension = "-TEXT"
Do
' ThisDrawing.Utility.GetEntity oEnt, Pt, "Select object for
'" & sNameExtension & "' layer creation"
sLayerName = oEnt.Layer
If InStr((UCase(sLayerName)), UCase(sNameExtension)) = 0 Then
sLayerName = sLayerName & sNameExtension
Set oLayer = ThisDrawing.layers.Add(sLayerName)
' You can set a whole range of layer features using the 'With'
' feature below.
With oLayer
.color = RGB(255, 0, 255)
.Linetype = "CONTINUOUS"
.Plottable = True
End With
ThisDrawing.ActiveLayer = sLayerName
' Option to move selected item to the layer if it is text of mtext
If TypeOf oEnt Is AcadText Or TypeOf oEnt Is AcadMText Then
oEnt.Layer = sLayerName
End If
End If
Loop Until Err <> 0
' Line above keeps code going till
' user presses <Esc> or fails to select an object.
MsgBox "No object selected, finishing program run"
End Sub

Back to top
fantum
Guest





Posted: Wed Mar 16, 2005 7:28 pm    Post subject: Re: Type mismatch error Reply with quote

The .ActiveLayer property wants a layer, not a string.

ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item(sLayerName)
Back to top
doug k
Guest





Posted: Wed Mar 16, 2005 8:09 pm    Post subject: Re: Type mismatch error Reply with quote

thanks, that worked well.

I'm sure I'll have more issues until this thing is fully-tuned, but its a
big help to have it running.

"fantum" <nospam@address.withheld> wrote in message
news:18881850.1110983365222.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
The .ActiveLayer property wants a layer, not a string.

ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item(sLayerName)


Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB