Kaup, Chester
Chester_Kaup at kindermorgan.com
Mon Sep 20 14:07:17 CDT 2010
I am using the following code in an attempt to link to a password protected spreadsheet. I am running it from a terminal server instance of Access 2007 if that matters. I get the following error message. Could it have anything to do with the spreadsheet asking if I want to enable macros when I open it manually? The file '-1' does not exist Here is the code: Sub LinkSpreadsheet() On Error GoTo LinkSpreadsheet_Err Dim varFileName As Variant Dim strPassword As String Dim db As Database Dim oExcel As Object, oWb As Object Set oExcel = CreateObject("Excel.Application") DoCmd.SetWarnings False Set db = CurrentDb() strPassword = "rig" varFileName = "F:\DATA\PUBLIC\Rig Schedule\Rig Schedule.xls" Set oWb = oExcel.Workbooks.Open(FileName:=varFileName, ReadOnly:=True,_ Password:=strPassword, UpdateLinks:=0, IgnoreReadOnlyRecommended:=True) DoCmd.TransferSpreadsheet acLink, 8, varFileName, True oWb.Close SaveChanges:=False DoCmd.SetWarnings True LinkSpreadsheet_Exit: oExcel.Quit Set oExcel = Nothing Exit Sub LinkSpreadsheet_Err: MsgBox Error$ Resume LinkSpreadsheet_Exit End Sub Chester Kaup Engineering Technician Kinder Morgan CO2 Company, LLP Office (432) 688-3797 FAX (432) 688-3799 No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.