hi, I am open a word file from open dialog box in rich text box.
i am using this code it open a word file but shows only text .i want to open file with text,images and bullets. -
Microsoft.Office.Interop.Word.ApplicationClass wordObject = new Microsoft.Office.Interop.Word.ApplicationClass();
-
object File = txtfilepath.Text; //this is the path
-
object nullobject = System.Reflection.Missing.Value;
-
Microsoft.Office.Interop.Word.Application wordobject = new Microsoft.Office.Interop.Word.Application();
-
wordobject.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
-
Microsoft.Office.Interop.Word._Document docs = wordObject.Documents.Open(ref File, ref nullobject, ref nullobject, ref nullobject,
-
ref nullobject, ref nullobject, ref nullobject, ref nullobject,
-
ref nullobject, ref nullobject, ref nullobject, ref nullobject,
-
ref nullobject, ref nullobject, ref nullobject, ref nullobject);
-
docs.ActiveWindow.Selection.WholeStory();
-
docs.ActiveWindow.Selection.Copy();
-
IDataObject data = Clipboard.GetDataObject();
-
rtbgermanfile.Text = data.GetData(DataFormats.Text).ToString();
-
string name = rtbgermanfile.Text.Trim();
-
name = String.Join(Environment.NewLine, name.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries));
-
string newtext = name.Replace("\n\n", "\n");
-
string newtext2 = newtext.Replace("\n\n", "\n");
-
rtbgermanfile.Text = newtext2.ToString();
-
txtwriteingerman.Text = rtbgermanfile.Lines[0];
-
docs.Close(ref nullobject, ref nullobject, ref nullobject);
-
wordobject.Quit(ref nullobject, ref nullobject, ref nullobject);
-
//wordobject.Quit(SaveChanges:false, OriginalFormat: false, RouteDocument: false);
-
System.Runtime.InteropServices.Marshal.ReleaseComObject(wordobject);
-
txtwriteinenglish.Focus();
-
Thanks in Advance.
1 2770 PsychoCoder 465
Recognized Expert Moderator Contributor
Well since you cannot show an image in a RichTextBox you're going to have to create your own custom user control that inherits from the RichTextBox in order for this to work
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: alikhome |
last post by:
Hi!
May be anybody knows...
I want to open word file (or Excel) from IIS server (URL) without
getting security window for input Username and password. I know
Username, Password and Domain. I'm trying to open with:
http://domain%5cUsername:password@URL
When my computer is registred in this domain - no problem. But if my
computer is not from...
|
by: Pablo Katcheroff |
last post by:
I'm working on a VB.NET project. I know that the RichTextBox component allows
me to use rich text (I mean with bold, underlined, etc); how can I make
Microsoft Word to get that rich text?
--
Regards,
Pablo
www.code.tectimes.com
|
by: Paolo |
last post by:
Friends,
I have created a form with a list box that shows all my Word files.
I have then added the following code (found on comp.databases
newsgroup) to the Open event of my form and it works fine:
Private Sub Form_Open(Cancel As Integer)
Dim file As String
Dim files As String
files = ""
|
by: Daniel |
last post by:
Hi,
I have opened the word file from database and display in web browser.
When i close the browser, i wan to update the changes into the database.
and i dont know how to achieve it.
I oni know when i upload the file, i need to use filefield control, but now
the situation is different. I cant automatically read the file location and...
|
by: senthilavs |
last post by:
Hi,
Im having word document in the Server Machine. While im trying to open the file in Client Machine file is opening in Server only. I need to open in the client only. This is an ASP.NET project done in VB.NET.
The Code i used to Open the file
---------------------------------------------
Dim oWordApplic As New Word.ApplicationClass
Dim...
| |
by: pazhaniraja |
last post by:
from my asp.net page we have to open word file,
in internet explore, word file opened perfectly.
but in Firefox its not working
please send solution asap thanks
|
by: deve8ore |
last post by:
Hello,
I have a dynamic named range that changes upon dropdown selection. The name of this range is "OutputFile".
When the macro clicks on it, you will be brought to a specific folder in Windows Explorer (NT) where and Output file exists. I would like to take this output file and convert into a text file (.txt).
I've tried many other...
|
by: arivusudar.nc |
last post by:
I have to open word document in web page using php coding in linux
server..
already i worte in windows supporting php code. but it is not working
in my linux server so, i need how to open word document in linux
server without COM class.
|
by: Ang |
last post by:
Hi,
I want to open a word file on background instead of showing the process
on client's screen. And then do mailmerge, after that allow user to
saveas. (user simply click the button and IE will ask user to open or
save as the file)
Below is the code but I donno how to do it on background. It's an aspx
program, thanks.
|
by: qfchen |
last post by:
How should I set different font, size for each text word in the same rich-text-box window? thanks
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |