+ Reply to Thread
Results 1 to 2 of 2

Excel VBA to search text in word and paste an image where it finds it

  1. #1
    Registered User
    Join Date
    04-13-2015
    Location
    milan
    MS-Off Ver
    office 2010
    Posts
    3

    Excel VBA to search text in word and paste an image where it finds it

    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.

  2. #2
    Registered User
    Join Date
    04-13-2015
    Location
    milan
    MS-Off Ver
    office 2010
    Posts
    3

    Re: Excel VBA to search text in word and paste an image where it finds it

    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Select Image In Excel Cell and paste to Word Doc Error 438
    By southcraven in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-15-2014, 06:48 AM
  2. How do you create a search engine that finds a row containing a certain word when searched
    By nathandavies in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2014, 06:30 AM
  3. Replies: 0
    Last Post: 04-22-2013, 12:13 PM
  4. Copy data range from excel to word as an image (i.e. paste special)
    By papasideris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2012, 09:54 AM
  5. Copy Paste from Excel to Word distorts image
    By Amphibia07 in forum Excel General
    Replies: 7
    Last Post: 10-29-2009, 11:11 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1