Solved

VBA - Exporting some contents of a userform to a Power point presentation

Posted on 2006-11-06
5
269 Views
Last Modified: 2013-12-26
Hi,

This question is related to VBA in Excel.

I have a userform with different controls on it.
I'd like to convert some controls to a picture and insert this in a Power point presentation.

How can I do that?

Thanx for your help.
0
Comment
Question by:Wongy
  • 2
5 Comments
 
LVL 13

Expert Comment

by:jmundsack
Comment Utility
I would recommend the following:

1. while the user form is open, press Alt-PrintScreen on the keyboard

(this copies the current form--as a picture--into the Windows clipboard)

2. go into PowerPoint
3. do Edit>Paste, or simply press Ctrl-V

Voila!
0
 
LVL 13

Expert Comment

by:jmundsack
Comment Utility
If you only want certain parts of the userform in the picture that you're inserting into PowerPoint, there are a couple options:

1. Instead of pasting the image into PowerPoint, paste it into the Windows "Paint" program
2. highlight the control(s) you want in the PowerPoint image and do Edit>Copy or simply press Ctrl-C
3. then go into PowerPoint
4. do Edit>Paste, or simply press Ctrl-V

Other option:

1. find and download a freeware or shareware "screen capture" utility that allows you to select a specific region of the screen and copy it to the clipboard.
2. go into PowerPoint
3. do Edit>Paste, or simply press Ctrl-V

HTH-Jon
0
 
LVL 1

Author Comment

by:Wongy
Comment Utility
Hi,

Actually I wanted to do this with VBA, so by just pressing a button. And I found the way.

Here it is:

First indeed we need to send the form to the clipboard.
==> cf http://support.microsoft.com/kb/240653/en-us

Then we export the content of the clipboard to PowerPoint. This way:

    Dim PPApp
    Dim PPPres
    Dim PPSlide, ppLayoutBlank
     
    Set PPApp = CreateObject("Powerpoint.Application")
     
    Set PPPres = PPApp.Presentations.Add
    Set PPSlide = PPPres.Slides.Add(1, 11)
     
    PPApp.Visible = True
    PPApp.ActiveWindow.View.Paste

    Set PPSlide = Nothing
    Set PPPres = Nothing
    Set PPApp = Nothing


Since I wanted to keep only certain controls on the form, before sending its content to the clipboard, I do this:
    For Each myCtrl In Me.Controls
        If Not LCase(myCtrl.Name) Like "*_show" Then
            myCtrl.Visible = False
        End If
    Next myCtrl

And I noticed that if I send now the content to the clipboard, all the content is sent (including the ones that are supposed to be hidden).
So I do this, before running the sub routine regarding the clipboard:

    newHour = Hour(Now())
    newMinute = Minute(Now())
    newSecond = Second(Now()) + 1
    waitTime = TimeSerial(newHour, newMinute, newSecond)

    Application.Wait waitTime


That's it.
Thanx.
0
 
LVL 1

Accepted Solution

by:
kodiakbear earned 0 total points
Comment Utility
Closed, 135 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

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!

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 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

13 Experts available now in Live!

Get 1:1 Help Now