![]() |
Excel: A document with the name is already open
This simple Excel automation from Access (both '97) is giving me
problems: 1. I do an OutputTo or a TransferSpreadsheet. 2. I use Automation to carry out one manipulation with Excel 3. I save the workbook and close the workbook and quit Excel. However, when I run Excel and open the workbook directly, I am still getting the "Document already open" dialog. I can't see Excel in TaskManager Apps or Processors before I launch Excel manually. Any help appreciated. Ananda ============ Code below: ================ DoCmd.OutputTo ObjectType:=acTable, _ objectname:=kstrTempTablename, _ outputformat:="MicrosoftExcel(*.xls)", _ Outputfile:=strFQN, _ Autostart:=False If fIsAppRunning("Excel") Then Set objXL = GetObject(, "Excel.Application") boolXLwasThere = True Else Set objXL = CreateObject("Excel.Application") boolXLwasThere = False End If objXL.Workbooks.Open strFQN Set objWBK = objXL.Workbooks(1) objWBK.Worksheets(1).Cells.EntireColumn.AutoFit objWBK.Save objWBK.Close SaveChanges:=False Set objWBK = Nothing If Not boolXLwasThere Then objXL.Quit End If Set objXL = Nothing ====== End Code =============== |
Excel: A document with the name is already open
Your Excel file associations may not be right. Toy correct this, from
Start-Run enter "Excel.exe /regserver" (w/o quotes, there is a space before the slash). -- Jim "AnandaSim" wrote in message ups.com... | This simple Excel automation from Access (both '97) is giving me | problems: | | 1. I do an OutputTo or a TransferSpreadsheet. | 2. I use Automation to carry out one manipulation with Excel | 3. I save the workbook and close the workbook and quit Excel. | | However, when I run Excel and open the workbook directly, I am still | getting the "Document already open" dialog. I can't see Excel in | TaskManager Apps or Processors before I launch Excel manually. | | Any help appreciated. | | Ananda | | | ============ Code below: ================ | | | DoCmd.OutputTo ObjectType:=acTable, _ | objectname:=kstrTempTablename, _ | outputformat:="MicrosoftExcel(*.xls)", _ | Outputfile:=strFQN, _ | Autostart:=False | | If fIsAppRunning("Excel") Then | Set objXL = GetObject(, "Excel.Application") | boolXLwasThere = True | Else | Set objXL = CreateObject("Excel.Application") | boolXLwasThere = False | End If | | objXL.Workbooks.Open strFQN | | Set objWBK = objXL.Workbooks(1) | | objWBK.Worksheets(1).Cells.EntireColumn.AutoFit | | objWBK.Save | | objWBK.Close SaveChanges:=False | | Set objWBK = Nothing | | If Not boolXLwasThere Then | objXL.Quit | End If | | Set objXL = Nothing | | ====== End Code =============== | |
Excel: A document with the name is already open
Hi Jim,
Many thanks for this. It worked. I was going barmy, trying Access OutputTo or TransferSpreadsheet or removing both and just using Automation. In fact, just before reading your reply, I even managed to make the error dialog appear even after a reboot - which points to the problem not being associated with an Excel process-in-memory issue, but something else. What did you twig onto the fact that it was an associations problem? Thanks again. Ananda Jim Rech wrote: Your Excel file associations may not be right. Toy correct this, from Start-Run enter "Excel.exe /regserver" (w/o quotes, there is a space before the slash). -- |
All times are GMT +1. The time now is 03:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com