ramesh_khade
asked on
Method ~ of object failed. ( -2146960888 Automation Error ) in VB-Excel Application.
Hi,
My VB-Excel application opens existing Excel File, applies Saveas method and
save the Excel file with new name at different folder and then opens
new excel files and write data in it and end.
I have developed application and installed at Client computer. It was working fine.
Now from last month, at client site, suddenly application stops working.
After rectification come to know that, Application is not able to open excel file at all.
Whenerevr application is trying to open workbook, it is above mentioned error.
My Code is like and line where i am getting error now at Client place but not my place.
Public ExcelApplication As Excel.Application
Public WorkBookExcel As Excel.Workbook
Public WorkSheetExcel As Excel.Worksheet
Set ExcelApplication = GetObject(, "Excel.Application") 'look for a running copy of Excel
If err.Number <> 0 Then 'If Excel is not running then
Set ExcelApplication = CreateObject("Excel.Applic ation") 'run it
End If
ExcelApplication.Applicati on.Visible = False
Set WorkBookExcel = ExcelApplication.Workbooks .Open("C:\ MyExcel.xl s", UpdateLinks:=False, ReadOnly:=True)
========================== ========== ========== ========== ========== ========== ===
.............
.............
Other statements.....
on Set WorkBookExcel line, I am getting above error.
But my place is working fine. I am not receiving any error.
My computer is with windows 2000 prof. SP3, Excel 97 and client computer also.
I am able to detect client has installed any extra patch or any update, so my application
get affected ?
What could be reason behind that ?
Can anybody help me regarding this
Waiting your reply.
Ramesh
My VB-Excel application opens existing Excel File, applies Saveas method and
save the Excel file with new name at different folder and then opens
new excel files and write data in it and end.
I have developed application and installed at Client computer. It was working fine.
Now from last month, at client site, suddenly application stops working.
After rectification come to know that, Application is not able to open excel file at all.
Whenerevr application is trying to open workbook, it is above mentioned error.
My Code is like and line where i am getting error now at Client place but not my place.
Public ExcelApplication As Excel.Application
Public WorkBookExcel As Excel.Workbook
Public WorkSheetExcel As Excel.Worksheet
Set ExcelApplication = GetObject(, "Excel.Application") 'look for a running copy of Excel
If err.Number <> 0 Then 'If Excel is not running then
Set ExcelApplication = CreateObject("Excel.Applic
End If
ExcelApplication.Applicati
Set WorkBookExcel = ExcelApplication.Workbooks
==========================
.............
.............
Other statements.....
on Set WorkBookExcel line, I am getting above error.
But my place is working fine. I am not receiving any error.
My computer is with windows 2000 prof. SP3, Excel 97 and client computer also.
I am able to detect client has installed any extra patch or any update, so my application
get affected ?
What could be reason behind that ?
Can anybody help me regarding this
Waiting your reply.
Ramesh
make sure both you and client machine has Excel 97. Excel 2000 is not backword compatible with some commands of excel 97. So if you want to use Excel 2000 commands, make sure you include Excel Objects Library 9.0.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi supunr,
On My Computer as well as Client's computer, both operation systems are same with service packs, Microsoft Excel 97 both are same. One months backs both places my program was working fine but suddenly at client's place it get stopped. I am understanding what extra windows patch or anything else client has installed, so that my program get affected ?
On My Computer as well as Client's computer, both operation systems are same with service packs, Microsoft Excel 97 both are same. One months backs both places my program was working fine but suddenly at client's place it get stopped. I am understanding what extra windows patch or anything else client has installed, so that my program get affected ?
i don't know if this any relevent...what about installing latest MDAC? Also try declaring variables as objects rather than excel objects.
You should try to run on client side your macro step by step. When the error will occure, you'll see where it stops and could try to resolve your problem.
Check the file for macro's, when opening the file using COM, by default, macro's are enabled. If the macro generates an error, or closes the document, it is possible that an atmation error is generated.
ASKER
Hi Supunr,
Your solution worked for just opening the excel files and manipulate data but not for
Statements like
WorkBookExcel.Sheets("SAMP LE").Selec t
ActiveWindow.SelectedSheet s.Visible = False
and
ActiveWindow.Zoom = 80
etc
IF I remove the reference from VB refereces and try to compile, it will give error at the time of compilation.
If I put the reference and compile it at client site for above statements, it is giving error.
Same error what I was getting prviously, Method ~ of object failed.
Ramesh
Your solution worked for just opening the excel files and manipulate data but not for
Statements like
WorkBookExcel.Sheets("SAMP
ActiveWindow.SelectedSheet
and
ActiveWindow.Zoom = 80
etc
IF I remove the reference from VB refereces and try to compile, it will give error at the time of compilation.
If I put the reference and compile it at client site for above statements, it is giving error.
Same error what I was getting prviously, Method ~ of object failed.
Ramesh
could you post some of your code in here (or email me sup
unr@hot
mai
l.com)
Set ExcelApplication = GetObject(, "Excel.Application") 'look for a running copy of Excel
If err.Number <> 0 Then 'If Excel is not running then
Set ExcelApplication = CreateObject("Excel.Applic ation") 'run it
End If
if (ExcelApplication is nothing) then exit sub
when you get "Method ~ of object failed" error, main reason for that is the method is not supported in the version of excel available in the computer. If you have direct access to this particular computer, try to create a macro in Excel itself and confirm the command/method that failed is supported in that excel.
unr@hot
mai
l.com)
Set ExcelApplication = GetObject(, "Excel.Application") 'look for a running copy of Excel
If err.Number <> 0 Then 'If Excel is not running then
Set ExcelApplication = CreateObject("Excel.Applic
End If
if (ExcelApplication is nothing) then exit sub
when you get "Method ~ of object failed" error, main reason for that is the method is not supported in the version of excel available in the computer. If you have direct access to this particular computer, try to create a macro in Excel itself and confirm the command/method that failed is supported in that excel.