VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Open user defined CHM using F1 or 'HELP

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
635 Views, 11 Replies

Open user defined CHM using F1 or 'HELP

The act of opening the CHM help file is no problem from VBA. However,
this particular routine does not use a dialog box, only a "select
objects" prompt. I want to allow the user to press "F1" or "'HELP" at
this point and have it open my CHM file.

In lisp, you can use (setfunhelp) to do this.

So in theory, if the VBA sub is called like this:
(defun c:foo ()(vl-vbaload "c:/program files/
directory>/sample/vba/drawline.dvb"))

...then the (setfunhelp) lisp function should work, but it doesn't.
Pressing "F1" or "'HELP" during the vba routine, simply opens the
AutoCAD HELP to the default page.

TIA

--
R.K. McSwain
http://rkmcswain.blogspot.com
11 REPLIES 11
Message 2 of 12
fxcastil
in reply to: Anonymous

Your post is not very clear, you first talk about
wanting to open the chm file while the user is selecting objects . Then you say "So in theory, if the VBA sub is called like this: (defun c:foo ()(vl-vbaload "c:/program files//sample/vba/drawline.dvb")) " ? The two subjects are not really related .

But anyway if you want to know if the user pressed the F1 key or any other key in VBA use the windows API
Public Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Long) As Integer

Search "GetAsyncKeyState" there are many examples of how to use this.

Fred Castillo
Message 3 of 12
Anonymous
in reply to: Anonymous

fxcastil said the following on 2/2/2006 9:13 AM:
> Your post is not very clear, you first talk about wanting to open
> the chm file while the user is selecting objects . Then you say "So
> in theory, if the VBA sub is called like this: (defun c:foo
> ()(vl-vbaload "c:/program files//sample/vba/drawline.dvb")) " ? The
> two subjects are not really related .

If you know what the lisp function (setfunhelp) does, then I think it's
pretty clear.


> But anyway if you want to know if the user pressed the F1 key or any
> other key in VBA use the windows API Public Declare Function
> GetAsyncKeyState Lib "user32" _ (ByVal vKey As Long) As Integer
>
> Search "GetAsyncKeyState" there are many examples of how to use this.

I was really looking for a VBA equivalent to (setfunhelp).
Maybe that explains it better.

--
R.K. McSwain
http://rkmcswain.blogspot.com
Message 4 of 12
fxcastil
in reply to: Anonymous

There is no equivalent to Lisp (setfunhelp) in VBA.
Use the windows API GetAsyncKeyState as mentioned.

Fred C
Message 5 of 12
Anonymous
in reply to: Anonymous

fxcastil said the following on 2/2/2006 11:08 AM:
> There is no equivalent to Lisp (setfunhelp) in VBA.

True.

That still doesn't explain why this doesn't work:

(defun C:foo () (vl-vbarun .....))
(setfunhelp "C:foo" "myhelp.chm" "topic")

Execute "foo" at the command line, press F1, and plain AutoCAD help appears.


--
R.K. McSwain
http://rkmcswain.blogspot.com
Message 6 of 12
Anonymous
in reply to: Anonymous

Lisp and vba run in different environments. As soon as foo loads the vba,
its done. So unless you can hit F1 really quick, what you're trying to do
won't work.

--
----
Ed
----
Message 7 of 12
fxcastil
in reply to: Anonymous

Ok now I know what your original post was leading too.
When you run execute (defun C:foo () (vl-vbarun .....))
you are in VBA all you did was use a command line fuction to exectute the VBA code.

The line below is not being executed at the time the VBA is executing the VBA drawline code.

(setfunhelp "C:foo" "myhelp.chm" "topic")

See link below for more on this same subject.
http://discussion.autodesk.com/thread.jspa?messageID=4149114

If you are using VBA it is best to do everthing in VBA except when there is absolutely no other way of doing things.
Most people who first learned Lisp then learned VBA always say "but I could do this in Lisp so much easier" . Yes Lisp does have more control over the drawing environment but VBA is light years ahead in working with windows or other applications.

Fred C
Message 8 of 12
Anonymous
in reply to: Anonymous

fxcastil said the following on 2/2/2006 2:17 PM:
>
> The line below is not being executed at the time the VBA is executing the VBA drawline code.
>
> (setfunhelp "C:foo" "myhelp.chm" "topic")

I don't think (setfunhelp) executes anything, except at the moment it is
called. It simply loads into memory the location of the help file to be
called when C:foo is running.

I think the problem here is that when [c:foo] is executed, it calls
(vl-vbarun....) which pushes [c:foo] up one on the command stack,
therefore when HELP is called, it runs help for (vl-vbarun...) instead
of for [c:foo]

--
R.K. McSwain
http://rkmcswain.blogspot.com
Message 9 of 12
Anonymous
in reply to: Anonymous

I always like when the same person posting a question answers thier own posts. But I thought the original question was how to intercept the F1 key while selecting objects in a VBA routine.

"The act of opening the CHM help file is no problem from VBA. However, this particular routine does not use a dialog box, only a "select objects" prompt. I want to allow the user to press "F1" or "'HELP" at this point and have it open my CHM file. "

I will be answering my post tomorrow !

Maximo
Message 10 of 12
benny
in reply to: Anonymous

Hi Mc Swain.

I dint understang your problem but, if u want to open a help file by pressing F1 when the vba prog is active all u need to do is createa command button in user form and write the code ' Sendkeys{F1}' for the click event.
else if u wnt to open by commandline ' (help"C: path").
All this works only if you associate a supported help file for your project by assignig helpcontex id.
bye.
Message 11 of 12
Anonymous
in reply to: Anonymous

benny said the following on 2/4/2006 12:57 AM:
> Hi Mc Swain.
>
> I dint understang your problem but,

Maybe you should re-read the OP, and possibly the whole thread.


> if u want to open a help file by pressing F1 when the vba prog is active all u need to do is createa command button in user form and write the code ' Sendkeys{F1}' for the click event.

There is no need to use "sendkeys". I had already mentioned in the OP
that I know how to open the desired help file, using the appropriate API
call.


> All this works only if you associate a supported help file for your project by assignig helpcontex id.

The proper help file *is* set in the project properties.




--
R.K. McSwain
http://rkmcswain.blogspot.com
Message 12 of 12
eddybeerke
in reply to: Anonymous

Is ther yet a solution? I just need it for my onwn commandline routine

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost