Help with util.InitializeUserInput use

Help with util.InitializeUserInput use

Anonymous
Nicht anwendbar
370Aufrufe
4Antworten
Nachricht 1 von 5

Help with util.InitializeUserInput use

Anonymous
Nicht anwendbar
Hello,

I am trying to use keywords in response to a getpoint function. For some
reason, VBA goes into an unhandled error. What am I doing wrong? I need
to pick a point or simply ENTER or type Open, Close, Fir Spline Xit in
response to getpoint.

See attached code below. Any pointers are greatly appreciated.

Regards
Rakesh


On Error Resume Next

kwdLst = "Open Close Fit Spline Xit"
util.InitializeUserInput 128, kwdLst

pt1 = util.GetPoint(, vbCrLf + "Pick first point:")

If Err Then
If StrComp(Err.Description, "User input is a keyword", 1) = 0 Then
' One of the keywords was entered
kwd = util.GetInput
util.Prompt "Keyword entered was: " + kwd
Else
util.Prompt "Error in point selection" + Err.Description
Err.Clear
End If
Err.Clear
End If

--

AutoCAD customization for Engineering/Mapping/GIS
Get GeoTools @ http://www.4d-technologies.com/geotools
Build MyGeoTools @
http://www.4d-technologies.com/geotools/my_geotools.htm
FREE downloads : http://www.4d-technologies.com/techcenter
0 „Gefällt mir“-Angaben
371Aufrufe
4Antworten
Antworten (4)
Nachricht 2 von 5

Anonymous
Nicht anwendbar
Hi there,
I could be wrong but I thought you needed to check what was in the Err
object rather than just assuming the object was there.
For example:

If Err.Number <> 0 Then
[Do something]
End If
By doing this as your first conditional test you can eliminate your nested
If-Then which checks for the Error description. Checking for an error
number is far easier than checking the error description.

Also note that the Err properties are automatically set ot zero or "" when
any form of the Resume statement is used. Even though the Clear method is
valid and useful there is no need to use it as you have done.

Hope that helps a little or even a lot.
Jason

Rakesh Rao wrote in message
news:3D5F5380.9A0F5138@vsnl.net...
>
> Hello,
>
> I am trying to use keywords in response to a getpoint function. For some
> reason, VBA goes into an unhandled error. What am I doing wrong? I need
> to pick a point or simply ENTER or type Open, Close, Fir Spline Xit in
> response to getpoint.
>
> See attached code below. Any pointers are greatly appreciated.
>
> Regards
> Rakesh
>
>
> On Error Resume Next
>
> kwdLst = "Open Close Fit Spline Xit"
> util.InitializeUserInput 128, kwdLst
>
> pt1 = util.GetPoint(, vbCrLf + "Pick first point:")
>
> If Err Then
> If StrComp(Err.Description, "User input is a keyword", 1) = 0 Then
> ' One of the keywords was entered
> kwd = util.GetInput
> util.Prompt "Keyword entered was: " + kwd
> Else
> util.Prompt "Error in point selection" + Err.Description
> Err.Clear
> End If
> Err.Clear
> End If
>
> --
>
> AutoCAD customization for Engineering/Mapping/GIS
> Get GeoTools @ http://www.4d-technologies.com/geotools
> Build MyGeoTools @
> http://www.4d-technologies.com/geotools/my_geotools.htm
> FREE downloads : http://www.4d-technologies.com/techcenter
>
>
0 „Gefällt mir“-Angaben
Nachricht 3 von 5

Anonymous
Nicht anwendbar
How can you get an error when you are using On Error Resume Next? The code
you posted below cannot be causing it directly, are you sure it is not
coming from another procedure that runs after what you have posted below?

Regards,
Jacob Dinardi


"Rakesh Rao" wrote in message
news:3D5F5380.9A0F5138@vsnl.net...
>
> Hello,
>
> I am trying to use keywords in response to a getpoint function. For some
> reason, VBA goes into an unhandled error. What am I doing wrong? I need
> to pick a point or simply ENTER or type Open, Close, Fir Spline Xit in
> response to getpoint.
>
> See attached code below. Any pointers are greatly appreciated.
>
> Regards
> Rakesh
>
>
> On Error Resume Next
>
> kwdLst = "Open Close Fit Spline Xit"
> util.InitializeUserInput 128, kwdLst
>
> pt1 = util.GetPoint(, vbCrLf + "Pick first point:")
>
> If Err Then
> If StrComp(Err.Description, "User input is a keyword", 1) = 0 Then
> ' One of the keywords was entered
> kwd = util.GetInput
> util.Prompt "Keyword entered was: " + kwd
> Else
> util.Prompt "Error in point selection" + Err.Description
> Err.Clear
> End If
> Err.Clear
> End If
>
> --
>
> AutoCAD customization for Engineering/Mapping/GIS
> Get GeoTools @ http://www.4d-technologies.com/geotools
> Build MyGeoTools @
> http://www.4d-technologies.com/geotools/my_geotools.htm
> FREE downloads : http://www.4d-technologies.com/techcenter
>
>
0 „Gefällt mir“-Angaben
Nachricht 4 von 5

Anonymous
Nicht anwendbar
Hi Jacob,

Thanks for your response.

Here is my full code:

I am unable to trap the keywords entered. Do you have a working example of how
to do it?


Sub Main()
Dim util As AcadUtility
Dim pickedPt, pt1, pt2 As Variant
Dim objName As AcadEntity
Dim ang As Double
Dim kwd, kwdLst As String

Set glAcad = GetObject(, "AutoCAD.Application")

Set util = glAcad.ActiveDocument.Utility

On Error Resume Next

util.Prompt vbCrLf + "Demonstrates use of utility objects for user
interaction."

Err.Clear

kwdLst = "Open Close Fit Spline Xit"

ThisDrawing.Utility.InitializeUserInput 128, kwdLst

pt1 = util.GetPoint(, "Pick first point:")

If Err.Number <> 0 Then
If Err.Description = "User input is a keyword" Then
' One of the keywords was entered
kwd = util.GetInput
util.Prompt "Keyword entered was: " + kwd
Else
util.Prompt "Error in point selection" + Err.Description
Err.Clear
End If
Err.Clear
End If

End Sub


Jacob Dinardi wrote:

> How can you get an error when you are using On Error Resume Next? The code
> you posted below cannot be causing it directly, are you sure it is not
> coming from another procedure that runs after what you have posted below?
>
> Regards,
> Jacob Dinardi
>
> "Rakesh Rao" wrote in message
> news:3D5F5380.9A0F5138@vsnl.net...
> >
> > Hello,
> >
> > I am trying to use keywords in response to a getpoint function. For some
> > reason, VBA goes into an unhandled error. What am I doing wrong? I need
> > to pick a point or simply ENTER or type Open, Close, Fir Spline Xit in
> > response to getpoint.
> >
> > See attached code below. Any pointers are greatly appreciated.
> >
> > Regards
> > Rakesh
> >
> >
> > On Error Resume Next
> >
> > kwdLst = "Open Close Fit Spline Xit"
> > util.InitializeUserInput 128, kwdLst
> >
> > pt1 = util.GetPoint(, vbCrLf + "Pick first point:")
> >
> > If Err Then
> > If StrComp(Err.Description, "User input is a keyword", 1) = 0 Then
> > ' One of the keywords was entered
> > kwd = util.GetInput
> > util.Prompt "Keyword entered was: " + kwd
> > Else
> > util.Prompt "Error in point selection" + Err.Description
> > Err.Clear
> > End If
> > Err.Clear
> > End If
> >
> > --
> >
> > AutoCAD customization for Engineering/Mapping/GIS
> > Get GeoTools @ http://www.4d-technologies.com/geotools
> > Build MyGeoTools @
> > http://www.4d-technologies.com/geotools/my_geotools.htm
> > FREE downloads : http://www.4d-technologies.com/techcenter
> >
> >

--

AutoCAD customization for Engineering/Mapping/GIS
Get GeoTools @ http://www.4d-technologies.com/geotools
Build MyGeoTools @ http://www.4d-technologies.com/geotools/my_geotools.htm
FREE downloads : http://www.4d-technologies.com/techcenter
0 „Gefällt mir“-Angaben
Nachricht 5 von 5

Anonymous
Nicht anwendbar
It looks like an external application not a VBA macro. In that case the
instruction

Set glAcad = GetObject(, "AutoCAD.Application")

only works if AutoCad is runnig. If Autocad is closed it generates an
unhandled error (as you referred).

The solution is well documented, you must begin in that way

On Error Resume Next
' Proceso de conexión con AutoCAD
Set aCAD = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set aCAD = CreateObject("AutoCAD.Application")
If Err Then
*** ERROR ***
End If
End If
0 „Gefällt mir“-Angaben