Link to home
Start Free TrialLog in
Avatar of MadMaxime
MadMaxime

asked on

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

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!
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

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
Avatar of MadMaxime
MadMaxime

ASKER

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)


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
you first have to make it visible before setting the windowstate
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
you could try a

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

this will rewrite all excel registry keys
or a faulty add in excel, from tools add-ins
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
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
ASKER CERTIFIED SOLUTION
Avatar of SpideyMod
SpideyMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial