Solved

Import Images from Word Document to Excel VBA

Posted on 2016-08-12
9
28 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 500 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 500 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

Technology Partners: 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!

Question has a verified solution.

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

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 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