2

The below code creates and opens a new Excel instance, but I couldn't see the opened Excel in my system despite setting the Visible property to True.

Could anyone help me with this?

Set Exobj = CreateObject("Excel.Application")

Set Newbook = Exobj.Workbooks.Add()

Exobj.Application.Visible = True

Newbook.SaveAs("C:\Users\ACER\Desktop\Project Folder\Test6.xlsx")

Exobj.Workbooks.Open("C:\Users\ACER\Desktop\Project Folder\Test6.xlsx")
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
user1925406
  • 713
  • 3
  • 15
  • 33
  • What happens when you run just the first 3 lines? Does Excel show up in the task bar? Does it show up in the processes tab of the task manager? – Ansgar Wiechers Feb 25 '13 at 16:48
  • 1
    I believe you need to make the Excel *object* visible. E.g. `Exobj.Visible = True` – mechanical_meat Feb 25 '13 at 16:48
  • Strange behavior of Excel.Application is often caused by zombies (not properly terminated instences of Excel left over from previous runs of the script). As Ansgar said: Use the Task manager to look whether you have *no* Excel before and exactly one Excel while running in the task list. – Ekkehard.Horner Feb 25 '13 at 16:54
  • Yes, after clearing excel in process in task manager and adding Exobj.Visible as true, am able to see it. Thank you all. – user1925406 Feb 25 '13 at 17:29
  • Please submit that as your own answer and accept later to avoid additional efforts from community. @Ekkehard.Horner - I'd submit your comment as an answer, that would be fair for OP to accept it) – Peter L. Feb 25 '13 at 18:05

1 Answers1

4

Strange behavior of Excel.Application is often caused by zombies (not properly terminated instences of Excel left over from previous runs of the script). As Ansgar said: Use the Task manager to look whether you have no Excel before and exactly one Excel while running in the task list.

Added:

See here for some background and a strategy to avoid Excel zombies.

Community
  • 1
  • 1
Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96