Solved

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

Posted on 2006-11-06
5
277 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

792 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