Тема: Вставка фото в документ
Добрый день!!!
имеется вот такой файлик для вставки фото в документ
не подскажите как такое же сделать, но что бы вставлял фото в определенную закладку в уже открытом документе,
я что то пытался сделать, переходит в закладку а дальше ни в какую, в чем проблема?
Sub Paste_Foto()
'Dim objWord As Object
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oTable As Word.Table
Dim sRows As Integer, sColumns As Integer
Dim r As Integer, c As Integer, t As Integer, w As Integer
Dim fs As New FileSystemObject
Dim fl As Folder
Dim f As File
Dim flist() As String 'масив файлов
Set fl = fs.GetFolder(ActiveDocument.Path & "\Фото\")
ReDim flist(fl.Files.Count)
w = 1
For Each f In fl.Files
flist(w) = f.Name
w = w + 1
Next
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
' Если Word-приложение не найдено, то создать новое
If Err Then
Set oWord = CreateObject("Word.Application")
End If
oWord.Visible = True
' При ошибке - на выход! :-)
'On Error GoTo exit_
' Если нет ни одного открытого Word-документа, то добавить новый
If oWord.Documents.Count = 0 Then oWord.Documents.Add
' Перейти в конец Word-документа
With oWord.ActiveDocument.Content
.Bookmarks("Фото_Объекта").Select
End With
'sColumns = 1
sColumns = InputBox("Число фото на листе в шириину")
sRows = -Int(-fl.Files.Count / sColumns)
'sRows = fl.Files.Count
Set oTable = oDoc.Tables.Add(oDoc.BookmarksoDoc.Bookmarks("\endofdoc").Range, sRows, sColumns)
oTable.Range.ParagraphFormat.SpaceAfter = 6
For r = 1 To sRows
For c = 1 To sColumns
t = c + sColumns * (r - 1)
On Error Resume Next: oTable.Cell(r, c).Range.FormattedText.InlineShapes.AddPicture FileName:=ActiveDocument.Path & "\Фото\" & flist(t), linktofile:=False, savewithdocument:=True
Next c
Next r
oTable.Rows(1).Range.Font.Bold = True
End Sub