Link to home
Start Free TrialLog in
Avatar of Bright01
Bright01Flag for United States of America

asked on

Printing Excel Output to a PPT

EE Professionals,

I have a Excel Workbook with a number of Graphics.  I would like to direct a "Print" or "Export to PPT" routine so as to "grab" a particular graphic and export it as a picture to powerpoint.  Does anyone have a sample export routine that exports graphics to PPT?   With a sample, I think I can take it from there.

Thank you in advance,

B.
Avatar of viralypatel
viralypatel
Flag of India image

you could just copy the graphics and past them as images into ppt, using paste special->image/bitmap option. To automate this you could simply record a macro.
SOLUTION
Avatar of Rob Henson
Rob Henson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bright01

ASKER

rob,

Is there a way to have the macro auto launch Powerpoint?  Can I create a standard "template" that it always uses for the output?  

Much thanks for hanging with me on this one.

B.
I cannot take any credit for the above script as it was pinched from a file which was written by somebody in our Head Office.

Searched VBA Help for Launch Application and found this command:

Application.ActivateMicrosoftApp xlMicrosoftWord

Open in new window


This checks for an open instance of an MS Application and activates it or launches it if none found.

I have just amended the last bit to xlMicrosoftPowerPoint and it opened PowerPoint with a blank document.

Not sure about the template!!

Thanks
Rob H
Rob,

I got the Open PPT Command to work, however, I get a compile error at the first line in the code you sent me;

PPApp As PowerPoint.Application

Could it be in conflict with the command for opening Powerpoint?

Any ideas?  

Thank you,

B.
Possibly, apologies I don't know much about cross application functions.

Thanks
Rob H
Rob,

I have a compile program error when I just use the code you provided above -- "Sub ChartToPPT()"   It stops at the specific line:

PPApp As PowerPoint.Application

Do you get the same error?

B.
hi B,

NOT FOR POINTS.

I think the key is in the first comment of the sub, "' Set a VBE reference to Microsoft PowerPoint Object Library". To do this, open the VBE, choose Tools - References, then click on/select the Reference called "Microsoft PowerPoint ##.# Object Library" where the # symbol is the version number.
If this doesn't fix your issue, can you please state exactly what the error message is?

Here is a link to one of Jon Peltier's page which you may also find useful:
http://peltiertech.com/Excel/XL_PPT.html

hth
Rob
Rob,

Thank you for the comments.  Rob H. can you specifically help me with this problem?

thank you,

B.
Broro183 and Robhenson,

Thank you for helping with this.  I set up a test Workbook so you could see exactly what's going on (the error).  As Rob has provided, I put his code in a module and assigned two buttons.  One button will launch PPT and the other is the one where I'm trying to transfer the graphic to a individual slide in PPT.  I really only need one button "Output" and what I'm attempting to do is to automatically transfer a set of graphics (only have 1 in the test Workbook but the real one would have several) to individual PPT slides.

You will see the error when you push the first button.

Thank you in advance,

B.
Output-Graphics.xlsm
hi B,

When I open the file I can't see any reference set to the powerpoint library. Have you followed my previous instructions...?

To do this, open the VBE, choose Tools - References, then click on/select the Reference called "Microsoft PowerPoint ##.# Object Library" where the # symbol is the version number.

Rob
Rob,

I apologize for my ignorance on this.  As you know I have a simple Workbook with graphics.  I want to have a macro that automatically opens Powerpoint and posts/pastes the graphics to individual PPT slides.   I'm not clear on why I need an Object Library.  Unfortunately, I don't know what an Object Library is.  Is it where I store a particular Template?  And what is the Version Number?  I've stored many a PPT but not sure I understand what a version number is beyond v1, v2, v3 at the end of a PPT I have modified.

Any direction or an example using the Workbook I attached here would be appreciated.

Thank you,

B.
B,

You need to Reference the Object Library because the phrase "Powerpoint." in the following declarations means "please search for whatever comes after the dot in the object library with the name that comes before the dot (in this case, 'powerpoint').
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

Open in new window

If you do not have a reference set up to the required library your code will error.

Object libraries are explained to some degree in the following links:
1) http://www.dicks-clicks.com/excel/olBinding.htm
2) "Libraries are components that provide functionality." in http://allenbrowne.com/ser-38.html
3) http://www.la-solutions.co.uk/content/mvba/MVBA-ObjectReferencing.htm
I'm out tonight, but I may try & find a better explanation for you at some stage...

The abbreviation VBE stands for "Visual Basic Editor" and it is what gets opened when you press [alt + F11] with Excel active. When you open the VBE and follow my instructions you will see a large list of possible References (aka Object Libraries) and as you scroll down the list you will see one that is called 'Microsoft PowerPoint ##.# Object Library'. The version number refers to the version of the particular application & for me it is "12.0" because I am using Office 2007. Your number may be different, depending on what version of office you have, but it is very likely to be the only Reference in your list that has a similar name.

Hopefully I have made things a bit clearer for you now & you will be able to follow my previous suggestion. If you really don't want to use "early binding", as explained in 1), which involves a Reference  then I/someone can modify your code for you, but I think the links will help you to be able to solve it yourself :-)

hth
Rob
Rob,

Thank you for the detailed explanation.  One consideration however, if others are going to use the Workbook and have not set up a Reference Object Library will they encounter the same problem?  If I understand you correctly, once I establish the Reference Object Library I can control what PPT I'm accessing correct?  So in the case I was using a template for instance, I would have it in the Library.  However this will not be the case for users who are using the Workbook and simply want to output the graphics.  You gave me the code to auto open Powerpoint, is there a simple way of pasting the graphics to the opened PPT?  Or is this a lot harder then I'm envisioning?

Much thanks,

B.
Rob,

Should I close this question out and restate what I'm trying to do?  I can auto. open PPT but do not know how to get it to post the graphs to a PPT slide.

Much thanks,

B.
hi B,

Sorry, I haven't been on E-E for a while. Others may think differently, but I think we should stay in this question until we give you a functional solution.


I've previously avoided giving a definition of a Reference Library because I may get some information wrong, but because I can't find a perfect link - here goes...
A Reference Library contains all the details of VBA objects/properties/methods (let's say keywords for now) of the specific application/object that it is named after. Libraries are effectively self contained "things" and the VBA in your file can use the keywords contained within the Referenced Libraries. If your VBA code uses a keyword and doesn't have a Reference set to the library that contains the keyword, your code will error. This is what you are experiencing. Using a Reference makes it much easier to develop code because you can use "early binding". Early Binding allows intelli-sense to work and also gives the other advantages listed in the various links.

Here are some more detailed links about Reference Libraries:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q245115
http://stackoverflow.com/a/6625774
http://www.excelguru.ca/content.php?176
or any of the other pages from this Google Search

>>One consideration however, if others are going to use the Workbook and have not set up a Reference Object Library will they encounter the same problem?
As long as they are using the same version of the application being Referenced, they should have no problems once you have set the Reference in the workbook as the details/identity of the Reference travels with the workbook. If they don't have the same version, they will still be able to open the file but when looking at the References in VBE - Tools - References, any problem Libraries will be prefixed with the word "MISSING". This is when the advantages of "Late Binding" come into play.
 
>> If I understand you correctly, once I establish the Reference Object Library I can control what PPT I'm accessing correct?
No, establishing the Reference gives you the ability to refer to the application's keywords in vba code. To be honest, you can control what ppt you are accessing whether you use early binding (with a Reference) or late binding (w/o a Reference). However, early binding makes it easier when developing (as you are currently doing).
>>So in the case I was using a template for instance, I would have it in the Library.  However this will not be the case for users who are using the Workbook and simply want to output the graphics.
The "library" is read only & is effectively a dictionary which tells the computer what the various vba keywords are (see above).

>>You gave me the code to auto open Powerpoint, is there a simple way of pasting the graphics to the opened PPT?  Or is this a lot harder then I'm envisioning?
The code that has been given does a lot more than just open PowerPoint (once you actually set the Reference). All your questions are good questions to help your understanding, but I'm still not clear if you have actually tried to set the Reference & then attempted any of the code. This seems to be in stark contrast to your initial comment that "With a sample, I think I can take it from there.".:-(
Have you read through the link on Jon Peltier's site that I've previously suggested. His site has numerous examples so it shouldn't be too hard.

HEY!!!
I'M SORRY, I've just been scrolling through the messages in the thread & I think this is the first time that I even noticed that you had attached a file. I'll look through it shortly and post a modified version of the file...

hth
Rob
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'll look at this later today....much thanks for your patience.

B.
Thank you for sticking with me on this!  Outstanding teamwork between both of you.  I can really use this and I believe there will be a number of people who will want to use your code here.  Again, "Thank You"........

B.
Thanks for the points, I'm pleased we could help :-)
I asked a related Question that may be easy for you to answer given you're familar with the code.   I"m trying to control the output to be placed on the same PPT.

Much thanks again for the original work.

B.