ActiveGML in Powerpoint
From GMLwiki
This is a step-by-step description of how to insert GML into a Powerpoint presentation. For this tutorial MS-Powerpoint 2007 is used, but it works on older versions as well.
Contents |
[edit] Tools needed
- MS Powerpoint 2007
- GMLStudio.NET (available at http://www.generative-modeling.org)
[edit] Insert the ActiveGML² control
Open a new or existing presentation in Powerpoint and go to the slide where you want to add GML. Select the "Developer" tab and click on the "More Controls" button (marked red in the next image). From the list select "ActiveGML2 Control" and place the control on the slide. (how to activate the "Developer" tap )
Now select the "Command button" and place the button control on the slide.
A doubleclick on the inserted button will lead you to the VBA editor of powerpoint.
Add the following code to the CommandButton1_Click() procedutre:
Private Sub CommandButton1_Click()
1 Dim filename As String
2 filename = Environ("temp") + "\somefile.xgml"
3 WriteFile_Chess (filename)
4 Me.ActiveGML21.LoadLibrary (filename)
5 Me.ActiveGML21.Call ("Chess.Board Chess.camPos1")
6 Kill(filename)
End Sub
Line 1 and 2 generate a filename. Line 3 writes the XGML to the file (how to create his is described below). Line 4 loads the file into the ActiveX control and line 5 executes GML statements. In this example to show the chess board. Line 6 does cleanup the file
[edit] Creating WriteFile_Chess
Start the GMLStudio.NET and open "Chessboard.xgml". From the "File" menu select "Export" and then "VBA". This will generate the VBA code for the procedure "WriteFile_Chess". The generated code is copied to the clipboard.
Switch to the VBA editor of powerpoint and paste the code from the clipboard. The inserted code will look similar to this:
Private Sub WriteFile_Chess(strFileName As String) Open strFileName For Output As #1 Print #1, "<?xml version='1.0' encoding='ISO-8859-1' ?>" Print #1, "<Library name=""Chess"">" Print #1, "<dict id=""_UTILS"">" ...
[edit] Enjoy :-)
When you start the presentation, the chessboard will appear on clicking the button on the slide. Check your Security Settings if the chessboard is not displayed.
[edit] Appendix A: Displaying the "Developer" tab
To enable the "Developer" tab, go to Powerpoint options, select "Popular" and check "Show Developer tab in the Ribbon".
[edit] Appendix B: Security Security
[edit] ActiveX Settings
Activate the "Developer" tab and select "Macro Security" from the toolbar. Change the "ActiveX Settings" from "Disable all controls without notification" to "Enable all controls..." or "Prompt me before enabling...".
[edit] Macro Settings
Activate the "Developer" tab and select "Macro Security" from the toolbar. Change the "Macro Settings" from "Disable all macros without notification" to "Enable all macros".

