Google Grupper har inte längre stöd för nya Usenet-inlägg eller -prenumerationer. Historiskt innehåll förblir synligt.
Dismiss

Q215484

13 visningar
Hoppa till det första olästa meddelandet

Jacob Yang

oläst,
5 juli 2002 01:38:542002-07-05
till
Hi George,

I am using PowerPoint2002. The following code is for your reference.

import msppt.*; // PowerPoint support. Use msppt9.* for 2000, and msppt.*
for 2002
import com.ms.com.*; // Variant & exception support.
import java.lang.InterruptedException; // Needed for Thread.sleep().


/**
* This class can take a variable number of parameters on the command
* line. Program execution begins with the main() method. The class
* constructor is not invoked unless an object of type 'Class1'
* created in the main() method.
*/
public class Class1
{
/**
* The main entry point for the application.
*
* @param args Array of parameters passed to the application
* via the command line.
*/
public static void main (String[] args)
{
// TODO: Add initialization code here
// Force COM objects to be created on the current thread.
// Otherwise, older VMs might not release all references
// and PowerPoint might continue to run after you shutdown.
ComLib.declareMessagePumpThread();

// Launch PowerPoint.
Application app = new Application();

// Add a presentation.
Presentation pres = app.getPresentations().Add(1);

// Add a slide with text layout.
Slide slide1 = pres.getSlides().Add(1, PpSlideLayout.ppLayoutText);
// Add text to slide.
slide1.getShapes().Item(new
Variant(1)).getTextFrame().getTextRange().setText("My first slide");
slide1.getShapes().Item(new
Variant(2)).getTextFrame().getTextRange().setText("Automating PowerPoint is
easy!\r\nUsing VJ++ is fun.");

// Add another slide, but with text and chart.
Slide slide2 = pres.getSlides().Add(2,
PpSlideLayout.ppLayoutTextAndChart);
// Add text to slide.
slide2.getShapes().Item(new
Variant(1)).getTextFrame().getTextRange().setText("Slide 2's topic");
slide2.getShapes().Item(new
Variant(2)).getTextFrame().getTextRange().setText("You can create and use
charts in your PowerPoint slides!");

// Add chart where default chart is.
{
Variant index = new Variant(3);
float top = slide2.getShapes().Item(index).getTop();
float width = slide2.getShapes().Item(index).getWidth();
float height = slide2.getShapes().Item(index).getHeight();
float left = slide2.getShapes().Item(index).getLeft();
slide2.getShapes().AddOLEObject(left, top, width, height,
"MSGraph.Chart", "", 0, "", 0, "", 0);
// Remove old/default chart.
slide2.getShapes().Item(index).Delete();
}

// Add another slide, but with text and org-chart.
Slide slide3 = pres.getSlides().Add(3, PpSlideLayout.ppLayoutOrgchart);
// Add title for this slide.
slide3.getShapes().Item(new
Variant(1)).getTextFrame().getTextRange().setText("The rest is only limited
by your Imagination");

// Add a new org chart where existing one is.
try{
Variant index = new Variant(2);
float top = slide3.getShapes().Item(index).getTop();
float width = slide3.getShapes().Item(index).getWidth();
float height = slide3.getShapes().Item(index).getHeight();
float left = slide3.getShapes().Item(index).getLeft();
slide3.getShapes().AddOLEObject(left, top, width, height,
"OrgPlusWOPX.4", "", 0, "", 0, "", 0);
// OrgPlusWOPX.4 is provided by the Microsoft Organization Chart
application.
// Remove old/default org-chart.
slide3.getShapes().Item(index).Delete();
}
catch (ComFailException e)
{
}
// Setup slide-show properties.
{
Variant varOpt = new Variant();
varOpt.noParam();
SlideShowTransition sst;
sst = pres.getSlides().Range(varOpt).getSlideShowTransition();
sst.setEntryEffect(PpEntryEffect.ppEffectRandom);
sst.setAdvanceOnTime(1);
sst.setAdvanceTime(5); // 5 seconds per slide
sst = null;
}
{
SlideShowSettings sss;
sss = pres.getSlideShowSettings();
sss.setShowType(PpSlideShowType.ppShowTypeKiosk);
sss.setLoopUntilStopped(1);
sss.setRangeType(PpSlideShowRangeType.ppShowAll);
sss.setAdvanceMode(PpSlideShowAdvanceMode.ppSlideShowUseSlideTimings);
// Run slide show...
sss.Run();
sss = null;
}

// Sleep for a while so user can watch slide show.
try {
Thread.sleep(15000);
} catch(InterruptedException e) {}

// Stop slide show.
try {
pres.getSlideShowWindow().getView().Exit();
} catch(ComFailException e) {}

// Clean up.
try{
pres.Close();
app.Quit();
slide3 = null;
slide2 = null;
slide1 = null;
pres = null;
app = null;
}
catch (ComFailException e)
{
}

}
}

Thanks,

Jacob Yang
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved

George Hester

oläst,
8 juli 2002 09:24:062002-07-08
till
Thanks Jacob.

--
George Hester
_________________________________
"Jacob Yang" <yang...@microsoft.com> wrote in message
news:b0tAuY#ICHA.5576@cpmsftngxa07...

0 nya meddelanden