how to open a word file thru my application  
Author Message
sniwas24x7





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

 

hi,

i need to open a word file.

i got that solved from a recent thread posted in this forum.

i opened it by using Process.Start("winword.exe","C:\myfile.doc");

but it opened in a new window.

what i need is,

i wanna open that file in  a panel ( a canvas) in my application Window.  How

thanX advance,

Sris



Visual Studio 200810  
 
 
Mubshir Raza Ali





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

Hi,

You add web browser control from toolbox and the load word document in it.
Even you can opend any document that browser support e.g. word, excel, pdf and swf etc...

Example Load Word
webBrowser1.Navigate("C:\\word.doc");

Example Load Excel
webBrowser1.Navigate("C:\\excel.xls");


Hope this help.



 
 
Ruurd Boeke





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

Do you mean the frame control I get a 'Failed to convert resource to object.' when I try to navigate to a word document.

 
 
Mubshir Raza Ali





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

Hi,

If you are programming C# or Vb open form in which you want to show the word document.
Goto the toolbox window at there will be Web Browser Control drag it to the form then use previouse statment to show the document.

Hope this help.



 
 
sniwas24x7





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

hi Boeke,  

i too got the same error when i tried to assign the url of my file to the Frame Control's Source.

 


 
 
sniwas24x7





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

hi mubshir,

thanx for the reply

and i program in c# code and even i'm working on a windows application. so i will not get a Web Browser Control.

so how can i do

thanX,

Sris


 
 
Mubshir Raza Ali





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

Hi,

Hi see below code to see how to ...
1. Declare
2. Add to form
3. and Nevigate a document in web browser control.



using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace WordDocinWB

{

public partial class Form1 : Form

{

//Declare

System.Windows.Forms.WebBrowser wb = new WebBrowser();

public Form1()

{

InitializeComponent();

//Dock fill

wb.Dock =DockStyle.Fill ;

//Add to form

this.Controls.Add (wb);

//Nevigate

wb.Navigate("C:\\word.doc");

}

}

}

Hope this help.







 
 
Ruurd Boeke





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

Mushir, I don't see a web browser in my toolbox. You are talking about avalon (wpf) applications aren't you not winform.

 
 
Mubshir Raza Ali





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

I was thinking and talking about developing using C# or VB.net in VS2005.

 
 
Ashish Shetty - MSFT





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

Ruurd, note the System.Windows.Forms namespace. Mubshir was referring to the WinForms Web Browser control.

 
 
Ruurd Boeke





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

Ruurd, note the System.Windows.Forms namespace. Mubshir was referring to the WinForms Web Browser control.

which is why I tried to subtly hint at him that he's posting in the avalon forum ;-)



 
 
sniwas24x7





PostPosted: Windows Presentation Foundation (WPF), how to open a word file thru my application Top

hi,

thanx for the reply mubshir,Ruurd, ashish.

one thing to make clear, I'm not working on WindowsForms.

i'm working on WinFx WindowsAplication, so can i use System.Windows.Forms within my application

if not how

thanX advance,

Sris