Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Import Images from Word Document to Excel VBA

Posted on 2016-08-12
9
Medium Priority
?
33 Views
Last Modified: 2016-09-13
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
Comment
Question by:martywal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
9 Comments
 

Author Comment

by:martywal
ID: 41754540
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
 

Author Comment

by:martywal
ID: 41754552
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
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 41754841
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!

 

Author Comment

by:martywal
ID: 41757149
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
 

Author Comment

by:martywal
ID: 41757177
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
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 2000 total points
ID: 41757330
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
 

Author Comment

by:martywal
ID: 41790598
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
 

Author Comment

by:martywal
ID: 41790600
Accept proposed allocation
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41795660
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question