Fine tuning a simple VBA application
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
Fine tuning a simple VBA application

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
RMS



Joined: 27 Aug 2005
Posts: 15

Posted: Sat May 12, 2007 1:28 am    Post subject: Fine tuning a simple VBA application Reply with quote

I use a dialog input box on all my VBA programs, is there code to end it after execution to remove that box from the cad window and make the cad window active again for drawing?


_________________
vacuum tube guitar amps www.dreamtone.org
Back to top
View user's profile Send private message Send e-mail
Fatty



Joined: 08 Jun 2006
Posts: 8
Location: Sankt-Petersburg, Russia

Posted: Sat May 12, 2007 6:20 pm    Post subject: Re: Fine tuning a simple VBA application Reply with quote

RMS wrote:
I use a dialog input box on all my VBA programs, is there code to end it after execution to remove that box from the cad window and make the cad window active again for drawing?

Hi

Did you try to add the OK button on this form?

Something like that should help I hope

Code:
Private Sub CommandButton1_Click()
Unload Me '// that means to unload your form
End Sub


~'J'~
Back to top
View user's profile Send private message
RMS



Joined: 27 Aug 2005
Posts: 15

Posted: Sun May 13, 2007 1:06 am    Post subject: Reply with quote

Well that does work, BUT it brings me back to the VBA Module. Is there any code that I can write to keep me in the active AutoCAD screen?


_________________
vacuum tube guitar amps www.dreamtone.org
Back to top
View user's profile Send private message Send e-mail
Fatty



Joined: 08 Jun 2006
Posts: 8
Location: Sankt-Petersburg, Russia

Posted: Sun May 13, 2007 7:33 am    Post subject: Reply with quote

RMS wrote:
Well that does work, BUT it brings me back to the VBA Module. Is there any code that I can write to keep me in the active AutoCAD screen?

I have not found link on thread where
was thrown the same question, here is a copy
of the answer
Citation:
"If you use The ACFocusCtrl and have a vbmodeless form then you can use this code
to switch from the userform back to your autocad window."
Code:

'//written by arcticad
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function SetActiveWindow Lib "user32" (ByVal hWnd As Long) As Long


Sub SwitchFocus()

Dim AcadHandle As Long
Dim FormHandle As Long
Dim acadApp As AcadApplication
Dim WindowReturn As Long
Set acadApp = GetObject(, "AutoCAD.Application")
AcadHandle = FindWindow(vbNullString, acadApp.Caption)
'<your code goes here>
'jump back to Acad
WindowReturn = SetActiveWindow(AcadHandle)

End Sub


The similar method with using of API function 'SetFocus'
Search google API-GUID 3.0 that has a very good
explanation of these functions with code

Hth

~'J'~
Back to top
View user's profile Send private message
Fatty



Joined: 08 Jun 2006
Posts: 8
Location: Sankt-Petersburg, Russia

Posted: Sun May 13, 2007 7:37 am    Post subject: Reply with quote

Here is another link that may helps

http://discussion.autodesk.com/thread.jspa?messageID=5201591

~'J'~
Back to top
View user's profile Send private message
 
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