Solved

Import Images from Word Document to Excel VBA

Posted on 2016-08-12
9
22 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
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Manipulate Range in Excel VBA 6 24
If help 9 49
sumifs excel 2013 3 16
multiple columns far out to BG need to transpose 6 16
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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 how to use longer labels with horizontal bar charts instead of the vertical column chart.

809 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