Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 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.009 c
14-100950
neuro
2003-07-14 20:48
2003.07.31
формат evt


1-100827
Алексей
2003-07-17 18:21
2003.07.31
DLL не найдена


4-101040
Avers
2003-05-29 15:58
2003.07.31
Выбор папок из текущего каталога


7-101010
L_Dmitrty
2003-05-20 11:09
2003.07.31
Записи


1-100755
bura
2003-07-16 12:39
2003.07.31
Интерфейс XP





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский