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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Late Bind Excel SaveAs

Status
Not open for further replies.

budbeth

Programmer
Oct 29, 2002
31
0
0
US
In VBA, I'm trying to open a .csv file and SaveAs a .xls file. It will work with early binding, but I have to use late binding due to different versions in use here. The following code will work up to the SaveAs line. Then I get an error #1004, "...Programmatic access to Visual Basic Project is not trusted."
Any suggestions as to what I need to change are welcome...


Public objExcel As Object

Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open strpath
With objExcel
.Visible = True
.DisplayAlerts = False
.ActiveWorkbook.SaveAs strpathNew, xlNormal
End With

budbeth
 
This question would be better served in the EXCEL forum

Randall Vollen
National City Bank Corp.
 
Sorry - I forgot to mention that I have the code on an Access form in a reporting interface database.

budbeth
 
If you change xlNormal to it's litteral value?

[tt] .ActiveWorkbook.SaveAs strpathNew, -4143 ' xlNormal[/tt]

Roy-Vidar
 
I was able to get the following to work:

Dim objXLApp As Object
Set objXLApp = CreateObject("Excel.Application")
objXLApp.Workbooks.Open strpath

With objXLApp
.DisplayAlerts = False
.ActiveWorkbook.Saved = True
.ActiveWorkbook.SaveAs strpathNew
.Cells.Select
.Selection.Columns.Autofit
.Range("A1").Select
.Visible = True
End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top