Active Member
Posts: 6
Registered: ‎10-11-2010
Message 11 of 14 (229 Views)

Re: Setting focus back to AutoCAD

08-15-2013 01:18 PM in reply to: jaboone

I haven't looked into the possibility to doing this through AutoCAD api but you could test using a Win32 API call.


This is one of the options posted in arcticad's reply. This just shows you which AutoCAD property to use. This is untested fyi.


Declare Auto Funtion SetForeGroundWindow Lib "User32.dll"(ByVal Hwnd As IntPtr) As Long

'Call these API's through your code



ADN Support Specialist
Posts: 669
Registered: ‎03-21-2011
Message 12 of 14 (195 Views)

Re: Setting focus back to AutoCAD

08-21-2013 06:49 AM in reply to: cjacobi

Another option that works in AutoCAD 2014 :



Developer Technical Services
Autodesk Developer Network

Valued Contributor
Posts: 54
Registered: ‎11-12-2012
Message 13 of 14 (156 Views)

Re: Setting focus back to AutoCAD

10-31-2013 05:59 AM in reply to: Balaji_Ram

I had to set this aside for a bit....I am only a part time programmer. Soooo, I had some time to try the last suggestion. I am working in VB not C# so I converted the code but get an error on the "Dynamic" type.


Dim acaddoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = acaddoc.Editor
        Dim acadDocObj As Dynamic = acaddoc.GetAcadDocument()

 My code does not like the Dynamic object???? I am running VS2010 with AutoCAD2014.


Any suggestions on what I'm doing wrong?





Valued Contributor
Posts: 54
Registered: ‎11-12-2012
Message 14 of 14 (142 Views)

Re: Setting focus back to AutoCAD

10-31-2013 08:18 AM in reply to: cjacobi

Well I tried something different and got an appropriate solution. I added the following before my MsgBox.

Excel now minimizes and then Autocad is the main visible application showing my message to the user.


Not sure why I didn't find this earlier but sometime a step away brings new ideas when you return.


thanks to everyone who provided responses.




myExcel.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlMinimized


You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community