VB to C#

P

Peter

Hello,
i have a VB Code to handle powerpoint presentations and need this code
in C# but i have no idea how to manage this.
Can anybody help me please, need this very urgent for my work!
Thanks a lot!

Peter

Code in VB:

Sub copy()
ActivePresentation.Slides.Range.Select
ActiveWindow.Selection.TextRange.Characters(Start:=1,
Length:=7).Select
ActiveWindow.Selection.Copy
ActivePresentation.Slides.Range.Select
ActiveWindow.Selection.TextRange.Characters(Start:=7,
Length:=0).Select
ActiveWindow.View.Paste
ActiveWindow.Selection.SlideRange.Shapes("Picture 3").Select
ActiveWindow.Selection.ShapeRange.Delete
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.ShapeRange.Delete
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 8").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 6").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.ShapeRange.Delete
End Sub
 
H

Helmut Obertanner

Hello Peter,

not tested, but should be something like this...

PP.ApplicationClass app = null;

app = new PP.ApplicationClass ();

// using PP = Microsoft.Office.Interop.PowerPoint ;

// using MSO = Microsoft.Office.Core ;



PP.Presentation activePresentation = app.ActivePresentation;

PP.DocumentWindow activeWindow = app.ActiveWindow ;

activePresentation.Slides.Range(1).Select();

activeWindow.Selection.TextRange.Characters (1,7).Select();

activeWindow.Selection.Copy();


activePresentation.Slides.Range(1).Select();

activeWindow.Selection.TextRange.Characters(7,0).Select();

activeWindow.View.Paste();

activeWindow.Selection.SlideRange.Shapes ["Picture
3"].Select(MSO.MsoTriState.msoCTrue );

activeWindow.Selection.ShapeRange.Delete();

activeWindow.Selection.SlideRange.Shapes["Rectangle
2"].Select(MSO.MsoTriState.msoCTrue );

activeWindow.Selection.ShapeRange.TextFrame.TextRange.Select();

activeWindow.Selection.ShapeRange.Delete();

activeWindow.Selection.SlideRange.Shapes["Rectangle
8"].Select(MSO.MsoTriState.msoCTrue );

activeWindow.Selection.ShapeRange.TextFrame.TextRange.Select();

activeWindow.Selection.SlideRange.Shapes["Rectangle
6"].Select(MSO.MsoTriState.msoCTrue );

activeWindow.Selection.ShapeRange.TextFrame.TextRange.Select();

activeWindow.Selection.ShapeRange.Delete();


--
Freundliche Grüße / with regards

Helmut Obertanner
Technical Consultant

Softwaredevelopment
DATALOG Software AG | Zschokkestr. 36 | D-80687 Munich
web: www.datalog.de


.... and IT works!
 
S

Steve Rindsberg

Peter said:
Hello,
i have a VB Code to handle powerpoint presentations and need this code
in C# but i have no idea how to manage this.
Can anybody help me please, need this very urgent for my work!
Thanks a lot!

I'd figure out how to rewrite it properly in VB/VBA to begin with.
It looks like macro recorder code, and it depends on the user selecting the
right stuff at the right time. As is, it won't do anything useful, I don't
think.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top