PDA

View Full Version : Excel Map gets destroyed when opened



monkeybonez
04-22-2009, 12:19 AM
Hi

i just want to open a excel map via VBS and run a makro,
i do this like followed:


Set XL = wscript.CreateObject("Excel.Application")
Set XLWorkBook = XL.Workbooks.Open(Path)
Set XLWorkSheet = XLWorkBook.WorkSheets.Item(1)
XL.run "AutoMark", "YES", "YES"


But if someone has different versions of office installed (2003/2007)
it tries to open excel 2007 maps (.xlsm) with office 2003 and gets an error.

This is since a Office Update from Microsoft in the last weeks.

So i tried to open the Map like this:


Set XL = GetObject(Path)
XL.Application.Run "'" & Dateipfad & "'" & "!Automark", "YES", "YES"


This worked just fine! But after i opened the map its not usable anymore!!
when i open the map in excel it is !!invinsible!! The makro still works but
i cant see the Worksheets anymore... this is so sick!

In the Makro itself, i set the application invinsible if it gets opened by script.
But that cant be the mistake because excel is visible, just the worksheet
is not viewed..

Maybe i dont close the "XL" object correct?

Thanks

Jan Karel Pieterse
04-22-2009, 02:35 AM
If you open the file and look in the window menu, is unhide enabled?

monkeybonez
04-22-2009, 05:04 AM
Hi, Thanks for your response!

I dont know wich menu you mean.

When i open the Map it looks like this (http://www.bilderkiste.org/show/original/6f8883510b9cbffae57cef7cdb648e30/Generell_(025).PNG) (sorry for german texts)

Andy Pope
04-22-2009, 05:56 AM
Try the ansicht tab.

View > Window

monkeybonez
04-22-2009, 09:44 AM
i will look it up tomorrow and response, i hope thats the deciding factor!

monkeybonez
04-22-2009, 11:40 PM
YES! Thats it !! Thank you so much..
But why do i have to do this? And how can i fix that problem

And there is one more thing:

At the and of the Makro, i ask the user if he wants to view the map (because it runs invinsible in the background)

If he sais "Yes" i execute following code:



ThisMap.Save
ThisMap.Application.Visible = True


After that, Excel Opens, but closes immediately!
Can it be that the Excel Object ("XL") i got in the script is terminated?

Just for understanding better:
The VBScript is in the Windows Autostart folder, and the only thing it
does is opening the map, and gives command to run the makro. The
Makro is editing a few things, and asks now if the user wants to view
the editet map.

monkeybonez
04-23-2009, 12:14 AM
Problem solved!! :friends:

Before saving the Map:



ThisMap.Parent.Windows(1).Visible = True


Now it works like i want it to work! I just dont understand why i
have to do this, because before the update i hadnt to set the window on visible..

THANKS FOR YOUR GREAT HELP!