ChrisOswald
Active Member
- Joined
- Jan 19, 2010
- Messages
- 454
Automating Excel from Access, I'm attempting to generate a single sheet workbook and save to a Sharepoint site. This process works fine on my machine (XL2007, XP), but on a coworkers computer (XL2003, XP), the code throws a 1004 error on the save as line. However, the really odd thing is that stepping through the code doesn't throw an error on the coworkers machine. Any ideas on what might be causing this behavior? Here's the sub being ran; the line it errors out on is the first branch in the .saveas block.
Code:
Private Const csSharePointSaveAs = "[URL="file://\\sharepoint-us.mycompany.com\sites\finance"]\\sharepoint-us.mycompany.com\sites\finance[/URL] admin\blah blah\blah-blah\Customer Publication Tracking.xls"
Private Sub PublishXLtoMOSS()
Dim objXL As Excel.Application 'Object
Dim wb As Excel.workbook 'Object
Dim ws As Excel.Worksheet 'Object
Dim rs As DAO.Recordset
Dim i As Long
'Set objXL = CreateObject("Excel.Application")
Set objXL = New Excel.Application
'objXL.Visible = True
Set wb = objXL.Workbooks.Add(-4167) 'xlWBATWorksheet
Set ws = wb.Worksheets(1)
Set rs = CurrentDb.OpenRecordset("tblPublicationCheckPoints")
rs.MoveFirst
For i = 0 To rs.Fields.Count - 1
ws.Cells(1, i + 1) = rs.Fields(i).Name
Next i
ws.Cells(2, 1).CopyFromRecordset rs
rs.Close
Set rs = Nothing
ws.Cells.EntireColumn.AutoFit
objXL.DisplayAlerts = False
If Val(objXL.Version) < 12 Then
'Here's the line with the odd error...
wb.saveas Filename:=csSharePointSaveAs, FileFormat:=-4143
Else
wb.saveas Filename:=csSharePointSaveAs, FileFormat:=56 'xl 98-03 fileformat
End If
wb.Close savechanges:=False
Set ws = Nothing
Set wb = Nothing
objXL.DisplayAlerts = True
objXL.Quit
End Sub