Scriptorium

us fr nl




VBA: Forms

Mailing a Userform Screenshot with Outlook directly from VBA
VBA does not have an object model for the Clipboard. To copy Images to the clipboard is possible but to paste images from the clipboard, for example a picture in an Outlook message, is not always (easily) possible from VBA code. This is actually quite strange because it is possible to do it from the mail composer in Outlook itself. In fact, a simple CTRL+v will already do the job. So how to do it from VBA then? This workbook demonstrates a trick to get the job done using the Chart object from Excel. This is one of the few objects that supports a method (Export) to save a picture to the hard disk. The sequence is as follows: 1) Use an API call to simulate the ALT+PRINTSCRN keypress which copies the Userform to the clipboard. 2) Create a chart in a worksheet and paste the picture in there. 3) Export (save) the chart to the hard disk 4) Create an email in Outlook, load the saved picture as an attachment and mail it.

Embedding flash movies on userforms using the Shockwave Flash Object library
This article demonstrates how to embed a flash movie in a userform in VBA. In the VBA Editor, go to the Control Toolbox and clik More Controls. scroll down to the Shockwave Flash Object and make sure it's selected. You can now use the Flash Object in VBA. 1) Drag the newly added control to your userform. You can resize the control at any point by dragging the sizing handles if you need to adjust it to the size of the animation. 2) Right-click the Shockwave Flash Object, and then click Properties. 3) In the value column (the blank cell next to Movie), type the full drive path including the file name (for example, C\\:My Documents\\MyFile.swf) or Uniform Resource Locator (URL) to the Flash file that you want to play. 4) To embed the Flash file so you can pass this presentation on to others, click True in the EmbedMovie property. (Note that in order for the Flash file to run the Shockwave Flash Object control must be registered on any computer that runs it.)

Print a form in landscape orientation
This sub routine has been placed under the Printing section. See: http://scriptorium.serve-it.nl/view.php?eid=1&sid=28

Creating a Form and Controls (Buttons, Listboxes etc.) at runtime with VBA code
This Sub procedure shows how the create and delete forms on the fly. Before using it, you'll need to set a reference in VBA to the VBA Extensibility library. In the VBA editor, go to the Tools menu, choose the References item, and put a check next to "Microsoft Visual Basic For Applications Extensibility" library. This enables VBA to find the definitions of these objects. If you are using Excel97, this library will appear in the References list without a version number: "Microsoft Visual Basic For Applications Extensibility". If you are using Excel 2000 or 2002, it will appear with a version number: "Microsoft Visual Basic For Applications Extensibility 5.3".

Atom Feed
Contact | About This Application | Scriptorium Website