Форум: "Основная";
Текущий архив: 2003.07.31;
Скачать: [xml.tar.bz2];
ВнизDelphi & Excel Найти похожие ветки
← →
Aleksei (2003-07-15 18:13) [0]При обращении к свойству ThisWorkBook объекта класса TExcelApplication получаю "OLE error 800A03EC"
Кусок кода привожу ниже:
var wb : _Workbook;
begin
if OpenDialog1.execute then begin
ExcelApplication1.Connect;
ExcelApplication1.WorkBooks.add(OpenDialog1.fileName,0);
wb := ExcelApplication1.ThisWorkBook[0]; // Здесь ломается
//или wb := ExcelApplication1.ThisWorkBook[getUserDefaultLCID()];
end;
end;
Мне надо получить обязательно ThisWorkBook (там используется макрос).
.
← →
Sandman25 (2003-07-15 18:16) [1]wb := ExcelApplication1.WorkBooks.add(OpenDialog1.fileName,0);
← →
Sandman25 (2003-07-15 18:18) [2]Вместо 0 должна быть константа Windows.LOCALE_USER_DEFAULT
← →
Aleksei (2003-07-16 09:10) [3]TExcelApplication.WorkBooks.add возвращает ActiveWorkBook, а мне нужен ThisWorkBook.
C Windows.LOCALE_USER_DEFAULT возвращается та же ошибка.
← →
Sandman25 (2003-07-16 10:11) [4]Я не знаю, что такое ThisWorkBook.
В MSDN нашел следующее. Возможно, Вам это что-то говорит и может помочь. Насколько я понял, ThisWorkBook есть не у всякого ExcelApplication.
You create a Microsoft® Excel add-in by creating a workbook, adding code and custom toolbars and menu items to it, and saving it as an Excel add-in file.
To create an Excel add-in
Create a new workbook, add code to it, and create any custom toolbars or menu bars.
On the File menu, click Properties. In the DocumentName Properties dialog box, click the Summary tab, and then use the Title box to specify the name for your add-in, as you want it to appear in the Add-Ins dialog box.
Compile the Add-In project by clicking Compile Project on the Debug menu in the Visual Basic Editor.
If you want, you can protect the project from viewing as described in Securing an Access, Excel, PowerPoint, or Word Add-in"s VBA Project.
Save the add-in workbook as type Excel add-in, which has the extension .xla.
Note When you are creating an Excel add-in, pay close attention to the context in which your code is running. When you want to return a reference to the add-in workbook, use the ThisWorkbook property, or refer to the workbook by name. To refer to the workbook that is open in Excel currently, use the ActiveWorkbook property, or refer to the workbook by name.
When you have saved the add-in, you can reopen it in Excel to make changes to the project. The saved add-in no longer has a visible workbook associated with it, but when you open it, its project is available in the Microsoft® Visual Basic® Editor.
Saving the add-in workbook as an Excel add-in sets the IsAddIn property of the corresponding Workbook object to True.
You can debug an Excel add-in while it is loaded. When you load an add-in, its project appears in the Solution Explorer in the Visual Basic Editor. If the project is protected, you must enter the correct password to view its code.
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2003.07.31;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.007 c