Excel object error : %1 is not a valid Win32 application

MadMaxime
MadMaxime used Ask the Experts™
on
When I create a VB6 application (under win2000 Adv. Server in remote control mode) and use Excel8.old and use following object :

   Dim Application As Excel.Application
   Set Application = New Excel.Application

I get following error message :

   Run-time error '-2147024703 (0800700c1)':
   Automation error
   %1 is not a valid Win32 application.

I don't know why! If I copy this code and compile it under windows XP I don't have any problem!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006

Commented:
Hello MadMaxime,

strange error but what i always do is design the app with early binding because you got all things you need and intellisense, when you distrubute use late binding because you can't be sure of version, service pack etc....

so i would try

first remove the excel reference then use the code

Dim Application As object
Set Application = createobject("Excel.Application")

HAGD:O)Bruintje

Author

Commented:
This method is ok, thank you.
But I still have a problem, I can't display the excel window. When I change the Window State (Application.WindowState = xlMaximized) I get an error (Run-time error '1004' : Unable to set the WindowState property of the Application class)


Top Expert 2006

Commented:
try

Sub t()
Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.WindowState = -4137
xlApp.Workbooks.Add
End Sub

HAGD:O)Bruintje
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Top Expert 2006

Commented:
you first have to make it visible before setting the windowstate

Author

Commented:
I get the same error "%1 is not a valid Win32 application" at line :
 
  Set xlApp = CreateObject("Excel.Application")

It's really a strange error, I'm trying to see if the error doesn't come from office, because in VB the two following methods should work (and work on my two other workstations)!:

  Dim Application As Excel.Application
  Set Application = New Excel.Application
  Application.Visible=True
  set Application = Nothing

and

  Sub t()
  Dim xlApp As Excel.Application
  Set xlApp = CreateObject("Excel.Application")
  xlApp.Visible = True
  xlApp.WindowState = -4137
  xlApp.Workbooks.Add
  End Sub
Top Expert 2006

Commented:
you could try a

-close Word
-startButton | Run: excel /regserver (there is a space before the switch)

this will rewrite all excel registry keys
Top Expert 2006

Commented:
or a faulty add in excel, from tools add-ins
Top Expert 2006

Commented:
guess my fault does this work? without error?

Sub t()
 Dim xlApp As object
 Set xlApp = CreateObject("Excel.Application")
 xlApp.Visible = True
 xlApp.WindowState = -4137
 xlApp.Workbooks.Add
End Sub

Author

Commented:
No, I can't create any office object except word;
Set xlApp = CreateObject("Word.Application") does work, but
Set xlApp = CreateObject("Excel.Application") doesn't work, Set xlApp = CreateObject("Access.Application") doesn't work,...

But sometimes it creates the object, and then two minutes later, without any reason it doesn't work...

I'm going crazy on this!
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- PAQ'd and points refunded
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

twalgrave
Cleanup Volunteer
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial