hi everyone,
im new and i have a lot of doubts .
I need to find a way to search a word in a word file and where this word is, to paste an image that is in my excel i.e some cells that i need to copy.
im stuck in the code, can someone help me.
hi everyone,
im new and i have a lot of doubts .
I need to find a way to search a word in a word file and where this word is, to paste an image that is in my excel i.e some cells that i need to copy.
im stuck in the code, can someone help me.
this is what i wrote but it always gets stuck when it finds tables. There has to be something easier
Sub Macro1()
'
b = 1
a = 2
c = 1
' Macro1 Macro
Do While Not Cells(a, 1) = ""
workdir = ThisWorkbook.Path + "\"
'
nomeout = workdir + Sheets(1).Cells(1, 2)
nomeinp = workdir + Sheets(1).Cells(1, 1)
Open nomeinp For Input As #1
Set wordapp = CreateObject("Word.Application")
sfilename = nomeinp
'cerca riga corrispondente nel DOC e.g. lifting
Do While Not Cells(17, 3) = "END OF FILE"
wordapp.Visible = True
wordapp.documents.Open (sfilename)
If sfilename = "False" Then Exit Sub
With wordapp.documents.Open(sfilename)
.Content.InsertAfter vbCr
.Paragraphs(b).Range.Copy
.Close SaveChanges:=False
End With
Cells(17, 3) = 0
Range("C17").Select
ActiveSheet.Paste
'incolla nel nuovo documento
If Cells(17, 3) = Cells(a, 1) Then
'apre excel da cui prende i dati
Workbooks.Open Filename:=workdir + Sheets(1).Cells(a, 3) + "\" + Sheets(1).Cells(a, 2), ReadOnly:=False
Range("A2:I47").Select
Selection.CopyPicture
Workbooks(2).Close SaveChanges:=False
wordapp.Visible = True
If sfilename = "False" Then Exit Sub
With wordapp.documents.Open(nomeout)
.Content.InsertAfter vbCr
.Paragraphs(b + c).Range.Paste
wordapp.Application.ActiveDocument.SaveAs nomeout
wordapp.documents.Close
End With
End If
b = b + 1
Loop
b = 1
a = a + 1
c = c - 1
Close #1
Cells(17, 3) = 0
' Workbooks(2).Close savechanges:=True
Loop
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks