Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Saving Excel Sheet in VB

Status
Not open for further replies.

Kchinnaswamy

IS-IT--Management
Jan 31, 2001
27
US
Hi

I have a problem when tring to save an Excel spread sheet in Visual Basic ( I can read the data with out any problem)

Here is my Code

Dim oExcel As Object
Set oExcel = CreateObject(sfile)
Set oSheet = oExcel.Worksheets(1)

oSheet.Cells(1,3).Value = 5

oExcel.Application.Quit
Set oExcel = Nothing


I am getting the following error when I say "yes" to save the excel spread sheet.

The Illegal operation when trying to open Excel is as follows

EXCEL caused an invalid page fault in
module <unknown> at 00e7:651447c6.
Registers:
EAX=00412d24 CS=0157 EIP=651447c6 EFLGS=00010206
EBX=00401b34 SS=015f ESP=0062fc1c EBP=00000000
ECX=00000002 DS=015f ESI=00401b34 FS=4d67
EDX=00430d0c ES=015f EDI=00449c10 GS=0000
Bytes at CS:EIP:

Stack dump:
65f1a46b 00449b84 817b6ab8 00449c10 00449c14 00000000 65f19b60 65f1a16c 65f19b60 00000000 fff4fcb1 00449c0c 817b6ab8 65f1a263 65f469e0 00449c0c

I don't know what I am missing here.

Please help. If you know of a better way to do it, Please suggest.

thanks

Kumar
 
Have you tried this?

==========
Dim oExcel As Object

Set oExcel = CreateObject(sfile)
Set oSheet = oExcel.Worksheets(1)

oSheet.Cells(1,3).Value = 5

oExcel.SaveCopyAs &quot;C:\My Documents\MySpreadsheet.xls&quot;

oExcel.Application.Quit
Set oExcel = Nothing

Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top