Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 34
  • Last Modified:

Import Images from Word Document to Excel VBA

Hi Experts,

I have recently opened a question and it has been largely answered (28960457). The bit that I'm now trying to do is extract the pictures from the word document to my Excel. GrahamSkan has been a huge help! I just wanted to simplify the question to keep it focused on the piece that is providing me with hassle.

What I don't know how to do is import the images from Word to Excel (the script will sit in Excel).

There are 3 images that I'm trying to bring in (I have indicated which ones in purple text - see attached). As you should be able to see there are headings and styling in the document which I hope may assist.

The target images and their destinations are as follows:

Under 1.6 High Level Timeline (heading style 2) the image needs to be inserted into a sheet called "Page 5 - Timetable" and a range in there called GANTTrange

Under 2.1 Costs (heading style 2) the image needs to be inserted into a sheet called "Page 2 - Proj Details" and a range in there called FundingProfile

There is also a further image Under 2.1 Costs (heading style 2) the image needs to be inserted into a sheet called "Page 3 - Financials" and a range in there called BudgetEstimate - Perhaps I need to create another heading above this image to do this - I do have that flexibility with the word document.

Anyway, I've been playing around with this and am hoping that by simplifying my question this may help resolve it.

Thanks in advance for all your help.

Martywal
Project-Handbook-v1-demox.docx
0
martywal
Asked:
martywal
  • 6
  • 2
2 Solutions
 
martywalAuthor Commented:
I was wondering if I could use something like this:

'This worked to get the gant chart and paste in the WordPaster
    wdDoc.InlineShapes(1).Range.Copy
    Worksheets("Page 4 - Timetable").Paste Destination:=Worksheets("Page 4 - Timetable").Range("GANTTrange")
   
    wdDoc.InlineShapes(2).Range.Copy
    Worksheets("Page 2 - Proj Details").Paste Destination:=Worksheets("Page 2 - Proj Details").Range("FundingProfile")
   
    wdDoc.InlineShapes(3).Range.Copy
    Worksheets("Page 3 - Financials").Paste Destination:=Worksheets("Page 3 - Financials").Range("BudgetEstimate")
   
I'm not too sure how the "InlineShapes(X)" index X operates...
0
 
martywalAuthor Commented:
As far as I can see inlineshapes only seems to recognise the GANTT as 'inline' does that seem right? Can I use another method?
0
 
GrahamSkanCommented:
The index for a inline shape matches its sequential position in a range, so
wdDoc.InlineShapes(3).Range.Copy

Open in new window

copies the third inline shape in the main text part of the document.

You can use the index, but if any of the pictures are liable to be missing, you will need something else to match the picture to its function and destination in the workbook.
1
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
martywalAuthor Commented:
Hi GrahamSkan, I have tried InlineShapes(3) to no avail. It can find and source (1) but when I've tried (3) it's not grabbing it. Any suggestions why?
0
 
martywalAuthor Commented:
It doesn't seem to work for (2) or (3) which makes me think it's because the shapes aren't 'inline'. Is there another way? I fear that the people using the document may not paste them 'inline' anyway...
0
 
GrahamSkanCommented:
It works OK for me.The third Inline shape is an image of a table with 'Funding Requested Breakdown' as the heading.

I haven't run code to paste it into a spreadsheet, but once in the clipboard I can manually paste it there or into another Word document.
0
 
martywalAuthor Commented:
Sorry guys, I went on holiday hence no update. Coming back and re-examining this issue it still remains. I've managed to agree a work around where the user copy's and pastes the images across, not ideal but the 'inline shapes' didn't want to do what I needed.
0
 
martywalAuthor Commented:
Accept proposed allocation
0
 
frankhelkCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- GrahamSkan (https:#a41754841)
-- GrahamSkan (https:#a41757330)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now