|
|
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
Кто знает как определить Range так чтоб когда открывается документ Word со всеми записями в самом конце строилась таблица в макро ето записывается .SELECTION.ENDKEY Unit:=wdStory kak ето написать в коде в vb? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2005, 13:58:08 |
|
||
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
Добавить References Word Librery Dim x As New Word.Application x.Documents.Add , , , 1 x.Selection.EndKey Unit:=wdStory x.Visible = True x.Quit 'закрыть word Set x = Nothing x будет являться твоим вордовским командным объектом ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2005, 14:08:26 |
|
||
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
я работаю с Object без Reference на такую строку Set wdRng = wordApp.Selection.EndKey(Unit:=wdStory) ругается пишет "bed parametr" ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2005, 14:20:27 |
|
||
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
Ну так замените wdStory на ее код: 6. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2005, 14:41:16 |
|
||
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
тогда кричит Run Time error '424' "object Required" ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2005, 14:48:12 |
|
||
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
не тадо ставить Set для перменной wdRng wdRng = Selection.EndKey (Unit:=wdStory, Extend:=wdMove) Может так пойдет ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2005, 15:13:24 |
|
||
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
Bad parameter Может есть еще идеи? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2005, 15:23:55 |
|
||
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
Напишите весь код процедуры ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2005, 15:26:29 |
|
||
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
Public Function ConvertMissionsFromAccessToWord(DocPath As String, TemplatePath As String, ProtocolID As Long) Dim cn As ADODB.Connection, rs As ADODB.Recordset, dbPath As String Dim SqlStr As String Dim TableWord As Object 'Word.Table Dim DocWord As Object 'Word.Document Dim celTable As Object 'Cell Dim rowTable As Object 'Row Dim wdRng As Object 'range 'Dim myRange As Object 'Range Dim i As Integer On Error GoTo Err_h: Set cn = New ADODB.Connection 'create connection dbPath = "C:\prdata2003.mdb" cn.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath & ";Persist Security Info=False" Set rs = New ADODB.Recordset rs.CursorLocation = adUseClient rs.CursorType = adOpenKeyset rs.LockType = adLockOptimistic rs.ActiveConnection = cn SqlStr = "Select mi_mision, mi_up_mision From t_mission where mi_pr_code = " + CStr(ProtocolID) + " ORDER BY mi_up_mision " rs.Open SqlStr, cn, adOpenStatic, adLockBatchOptimistic, adCmdText If rs.RecordCount > 0 Then Call OpenWord 'open word application wordApp.Documents.Add TemplatePath 'path of tamplate wordApp.ActiveDocument.SaveAs DocPath 'Save tamplate as a file we need create Set DocWord = wordApp.ActiveDocument Set wdRng = wordApp.Selection.EndKey(6) --->кричит Set TableWord = wordApp.ActiveDocument.Tables.Add(wdRng, NumRows:=rs.RecordCount * 3, NumColumns:=1) rs.MoveFirst Dim str As String, k As Integer str = rs.Fields("mi_up_mision") k = 0 For i = 1 To rs.RecordCount TableWord.Cell(i + k, 1).Range.Text = rs.Fields("mi_up_mision") next wordApp.Visible = True Set wordApp = Nothing 'close recordset rs.Close Set rs = Nothing 'close connection cn.Close Set cn = Nothing ConvertMissionsFromAccessToWord = True Exit Function Err_h: MsgBox Err.Description + Err.Number 'Set wdRng = Nothing Set wordApp = Nothing 'close recordset rs.Close Set rs = Nothing 'close connection cn.Close Set cn = Nothing ConvertMissionsFromAccessToWord = False End Function Private Sub OpenWord() On Error GoTo Err_h: If Not wordApp Is Nothing Then Set wordApp = GetObject(, "Word.Application") Else Set wordApp = CreateObject("word.Application") End If Exit Sub Err_h: MsgBox ("") End Sub ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2005, 15:32:33 |
|
||
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
Спасибо Уже не важно Я поставила bookmark Просто хотелось обоитись без него ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2005, 15:55:09 |
|
||
|
word .SELECTION.ENDKEY
|
|||
|---|---|---|---|
|
#18+
И правильно, что кричит. EndOf Method возвращает не Range, а EndOf MethodThis method returns a value that indicates the number of character positions the range or selection was moved or extended (movement is forward in the document). Надо так: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 22.11.2005, 08:45:35 |
|
||
|
|

start [/forum/topic.php?fid=60&fpage=304&tid=2166832]: |
0ms |
get settings: |
6ms |
get forum list: |
10ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
64ms |
get topic data: |
7ms |
get forum data: |
2ms |
get page messages: |
31ms |
get tp. blocked users: |
1ms |
| others: | 185ms |
| total: | 310ms |

| 0 / 0 |
