Solved

Import Images from Word Document to Excel VBA

Posted on 2016-08-12
9
17 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
  • 6
  • 2
9 Comments
 

Author Comment

by:martywal
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:martywal
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:martywal
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Accept proposed allocation
0
 
LVL 13

Expert Comment

by:frankhelk
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now