Author Topic: Set focus to Excel and back  (Read 2813 times)

0 Members and 1 Guest are viewing this topic.

CincyJeff

  • Newt
  • Posts: 89
Set focus to Excel and back
« on: December 07, 2015, 09:23:10 AM »
I'm working on a program that needs user input to select Excel cells so I can import data. I have Excel open and the application object but I don't know how to change program focus from lisp to Excel and back as I process a list of data. I can read the current active cell, but I can't pause the lisp to allow the user to select a different cell. Any ideas or help?

CincyJeff

  • Newt
  • Posts: 89
Re: Set focus to Excel and back
« Reply #1 on: December 07, 2015, 09:57:51 AM »
I've tried (vlax-invoke-method *excelapp* 'ActivateMicrosoftApp) and (vlax-invoke-method *excelapp* 'ActivateMicrosoftApp "Excel.Application") but no good so far.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Set focus to Excel and back
« Reply #2 on: December 07, 2015, 12:01:24 PM »
I've not tested to determine whether what you are looking to achieve is actually possible, but my first thought would be that you could use the appactivate method of the WSH to switch focus to Excel & back.

CincyJeff

  • Newt
  • Posts: 89
Re: Set focus to Excel and back
« Reply #3 on: December 07, 2015, 01:22:24 PM »
I tried
Code - Auto/Visual Lisp: [Select]
  1.       'appactivate "Microsoft Excel - Filename.xlsx")
but it doesn't pause for user input.
Am I using this correctly?

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Set focus to Excel and back
« Reply #4 on: December 07, 2015, 04:33:54 PM »

CincyJeff

  • Newt
  • Posts: 89
Re: Set focus to Excel and back
« Reply #5 on: December 08, 2015, 11:50:25 AM »
VovKa,
That link did the trick. The getstring halts AutoCAD until you activate the Excel window, select an active cell, re-activate AutoCAD, and press enter. That just saved me a lot of programming. Thanks for the response.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Set focus to Excel and back
« Reply #6 on: December 08, 2015, 12:20:41 PM »
I tried
Code - Auto/Visual Lisp: [Select]
  1.       'appactivate "Microsoft Excel - Filename.xlsx")
but it doesn't pause for user input.
Am I using this correctly?

My suggestion didn't include the 'pause', but rather was a suggestion of how to switch focus between applications.