Fox_killer 0 Posted February 24, 2011 Report Share Posted February 24, 2011 Boas pessoal, Alguém sabe como se faz para abrir um ficheiro powerpoint directamente na form? Eu encontrei algumas coisas na internet mas o que encontrei não abria o ficheiro na form mas sim num documento aparte e não é o que quero...alguém me consegue ajudar? Link to post Share on other sites
apocsantos 206 Posted February 25, 2011 Report Share Posted February 25, 2011 Boa tarde, Se mostrares o código talvez seja mais fácil ajudar. Adiciona a referencia para o powerpoint object library, e confirma que tenhas o powerpoint interops instalado. using PowerPoint = Microsoft.Office.Interop.PowerPoint; PowerPoint.Application oPPT; PowerPoint.Presentations objPresSet; //the location of your powerpoint presentation string strPres; strPres = @"mpPres.ppt"; //Create an instance of PowerPoint. oPPT = new PowerPoint.ApplicationClass(); // Show PowerPoint to the user. oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; objPresSet = oPPT.Presentations ; //open the presentation objPres = objPresSet.Open ( strPres,MsoTriState.msoFalse , MsoTriState.msoTrue ,MsoTriState.msoTrue ); Cordiais cumprimentos, Apocsantos "A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito" Link to post Share on other sites
Fox_killer 0 Posted February 25, 2011 Author Report Share Posted February 25, 2011 Boa tarde, Eu tentei utilizar o que está aqui no site (http://support.microsoft.com/kb/304662) mas não consegui porque não encontro as dll que são pedidas, não sei se é por eu utilizar o Visual C# 2008... Link to post Share on other sites
apocsantos 206 Posted February 25, 2011 Report Share Posted February 25, 2011 Boa noite, Pelo que vi do exemplo, optaste pelo "caminho mais longo possivel", para abrir a apresentação. Criar um web browser, para abrir uma apresentação ppt, é quase como para ir do Porto a Lisboa, dar a volta por Madrid. Adiante, existem caminhos mais curtos, o exemplo que deixei acima é um deles. As bibliotecas que te faltam parecem ser as do Office Interop. Vê este link: http://msdn.microsoft.com/en-us/library/ff759900.aspx Aqui encontras bastante informação, que te pode ajudar a fazer a interacção entre o Powerpoint e o C# Cordiais cumprimentos, Apocsantos "A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito" Link to post Share on other sites
Fox_killer 0 Posted February 26, 2011 Author Report Share Posted February 26, 2011 Bom dia, Segui o código de exemplo que mostras-te e deu-me dois erros diferentes, o primeiro eu consegui resolver agora o segundo não estou a saber resolver. Este é o código que tenho: private void button1_Click(object sender, EventArgs e) { PowerPoint.Application oPPT; PowerPoint.Presentations objPresSet; PowerPoint._Presentation objPres; //the location of your powerpoint presentation string strPres; strPres = @"mpPres.ppt"; //Create an instance of PowerPoint. oPPT = new PowerPoint.ApplicationClass(); // Show PowerPoint to the user. oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; objPresSet = oPPT.Presentations; //open the presentation objPres = objPresSet.Open(strPres, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue); } Dava erro no "objPres" e eu procurei na internet e encontrei esta linha de código "PowerPoint._Presentation objPres;" acrescentei e pronto problema resolvido. Mas continua a dar erro no "MsoTriState" e não consigo resolver. Será que me podes ajudar? Link to post Share on other sites
apocsantos 206 Posted February 26, 2011 Report Share Posted February 26, 2011 Bom dia, Aparentemente falta declarar o MsoTriState, que faz parte na namespace Microsoft.Office.Core . private void button1_Click(object sender, EventArgs e) { Public Enum MsoTriState; PowerPoint.Application oPPT; PowerPoint.Presentations objPresSet; PowerPoint._Presentation objPres; //the location of your powerpoint presentation string strPres; strPres = @"mpPres.ppt"; //Create an instance of PowerPoint. oPPT = new PowerPoint.ApplicationClass(); // Show PowerPoint to the user. oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; objPresSet = oPPT.Presentations; //open the presentation objPres = objPresSet.Open(strPres, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue); } Cordiais cumprimentos, Apocsantos "A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito" Link to post Share on other sites
Fox_killer 0 Posted February 26, 2011 Author Report Share Posted February 26, 2011 Boa tarde, Muito obrigada pela ajuda, o código ainda está a dar uns erros mas já está melhor que aquilo que estava Obrigada Link to post Share on other sites
apocsantos 206 Posted February 26, 2011 Report Share Posted February 26, 2011 Boa noite, Dispõe Se colocares cá os erros posso tentar ver o que está a correr de errado Cordiais cumprimentos, Apocsantos "A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito" Link to post Share on other sites
Fox_killer 0 Posted February 27, 2011 Author Report Share Posted February 27, 2011 Boa tarde, namespace WindowsFormsApplication2 { public enum MsoTriState { } public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { PowerPoint.Application oPPT; PowerPoint.Presentations objPresSet; PowerPoint._Presentation objPres; //the location of your powerpoint presentation string strPres; strPres = (@"caminho.ppt"); //Create an instance of PowerPoint. oPPT = new PowerPoint.ApplicationClass(); // Show PowerPoint to the user. oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; objPresSet = oPPT.Presentations; //open the presentation objPres = objPresSet.Open(strPres, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue); } } } Diz que 'WindowsFormsApplication2.MsoTriState' não contém uma definição para "msoTrue" e "msoFalse" Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now