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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sporenzaConnect With a Mentor Author 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
 
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
 
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
All Courses

From novice to tech pro — start learning today.