Trying to Save a File in Excel with VB.NET

Ok my program is attached very simple, I get an error before I see the After Save text...

This exe works fine on my development machine but not on a different machine....

Unhandled Exception: System.Runtime.InteropServices.COMException (0x800A03EC): SaveAs method of Work
   at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, St
ring[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, Str
uments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
   at ConsoleApplication1.Module1.Main()

Imports System.IO
Imports System.Console
 
Module Module1
 
    Sub Main()
 
        Dim excelApplication As Object = CreateObject("Excel.Application")
        Dim excelWorkbook As Object = excelApplication.Workbooks.Add()
 
        excelWorkbook = excelApplication.ActiveWorkbook
        WriteLine("Before Save")
        excelWorkbook.SaveAs(filename:="C:\Test", FileFormat:=56)
        WriteLine("After Save")
        Exit Sub
 
 
    End Sub
 
 
End Module

Open in new window

sporenzaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PHeadlandCommented:
Do you have permission to write to C: on the second machine?
0
sporenzaAuthor Commented:
yes I can create the file my self, also the file does not exist
0
sporenzaAuthor Commented:
opps here is the full error:

Unhandled Exception: System.Runtime.InteropServices.COMException (0x800A03EC): SaveAs method of Workbook class failed
   at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, St
ring[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arg
uments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
   at ConsoleApplication1.Module1.Main()
0
sporenzaAuthor Commented:
well after hours and hours of trying to figure out what was wrong, i figured it out...

they had a "demo" version of excel 2007 that does not allow you to create files!!! with excel!!! So I could make a file such as a .txt just not an exel file!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ghendricCommented:
I've been getting this error too from a user that has their operating system kind of locked down. Would something in Component Services need to be set to fix this issue?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.