Solved

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

Posted on 2006-11-06
5
275 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
ID: 17883098
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
ID: 17883117
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
ID: 17884133
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
ID: 17975509
Closed, 135 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 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