• Авторизация


Вопрос к программистам по СОМ 04-12-2007 15:20 к комментариям - к полной версии - понравилось!


Есть документ Word. В нем есть поля форм. Документ закрыт так, что текст можно вводить толкьо в поля. Программно могу добраться до документа. А вот как писать свой текст в поля - не знаю.
КомОбъект.FormFields есть.
Но по индексу значения не получить:
КомОбъект.FormFields[1] {(1)}: Получение элемента по индексу для значения не
определено

КомОбъект.FormFields["Pole2"] {(1)}: Поле объекта не обнаружено (Pole2)

КомОбъект.FormFields.Pole2 {(1)}: Поле объекта не обнаружено (Pole2)
вверх^ к полной версии понравилось! в evernote
Комментарии (2):
T100-ZaRaZa 04-12-2007-15:30 удалить
Берешь, читаешь хелп к VB for Application. COM тут непричем )

Word Developer Reference

FormFields.Item Method
Returns an individual FormField object in a collection.

Syntax:

expression.Item(Index)

expression Required. A variable that represents a FormFields collection.
Ефр 04-12-2007-15:54 удалить
Using the FormField Object

Use FormFields(index), where index is a bookmark name or index number, to return a single FormField object. The following example sets the result of the Text1 form field to "Don Funk."

ActiveDocument.FormFields("Text1").Result = "Don Funk"
The index number represents the position of the form field in the selection, range, or document. The following example displays the name of the first form field in the selection.

If Selection.FormFields.Count >= 1 Then
MsgBox Selection.FormFields(1).Name
End If
Use the Add method with the FormFields object to add a form field. The following example adds a check box at the beginning of the active document and then selects the check box.

Set ffield = ActiveDocument.FormFields.Add( _
Range:=ActiveDocument.Range(Start:=0, End:=0), _
Type:=wdFieldFormCheckBox)
ffield.CheckBox.Value = True
Remarks
Use the CheckBox, DropDown, and TextInput properties with the FormField object to return the CheckDown, DropDown, and TextInput objects. The following example selects the check box named "Check1."

ActiveDocument.FormFields("Check1").CheckBox.Value = True


Комментарии (2): вверх^

Вы сейчас не можете прокомментировать это сообщение.

Дневник Вопрос к программистам по СОМ | community_coding - Сообщество программистов | Лента друзей community_coding / Полная версия Добавить в друзья Страницы: раньше»