473,413 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

How to open word file with images and bullets in a rich text box

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.
Expand|Select|Wrap|Line Numbers
  1. Microsoft.Office.Interop.Word.ApplicationClass wordObject = new Microsoft.Office.Interop.Word.ApplicationClass();
  2.                 object File = txtfilepath.Text; //this is the path
  3.                 object nullobject = System.Reflection.Missing.Value;
  4.                 Microsoft.Office.Interop.Word.Application wordobject = new Microsoft.Office.Interop.Word.Application();
  5.                 wordobject.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
  6.                 Microsoft.Office.Interop.Word._Document docs = wordObject.Documents.Open(ref File, ref nullobject, ref nullobject, ref nullobject,
  7.                 ref nullobject, ref nullobject, ref nullobject, ref nullobject,
  8.                 ref nullobject, ref nullobject, ref nullobject, ref nullobject,
  9.                 ref nullobject, ref nullobject, ref nullobject, ref nullobject);
  10.                 docs.ActiveWindow.Selection.WholeStory();
  11.                 docs.ActiveWindow.Selection.Copy();
  12.                 IDataObject data = Clipboard.GetDataObject();
  13.                 rtbgermanfile.Text = data.GetData(DataFormats.Text).ToString();
  14.                 string name = rtbgermanfile.Text.Trim();
  15.                 name = String.Join(Environment.NewLine, name.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries));
  16.                 string newtext = name.Replace("\n\n", "\n");
  17.                 string newtext2 = newtext.Replace("\n\n", "\n");
  18.                 rtbgermanfile.Text = newtext2.ToString();
  19.                 txtwriteingerman.Text = rtbgermanfile.Lines[0];
  20.                 docs.Close(ref nullobject, ref nullobject, ref nullobject);
  21.                 wordobject.Quit(ref nullobject, ref nullobject, ref nullobject);
  22.                 //wordobject.Quit(SaveChanges:false, OriginalFormat: false, RouteDocument: false);
  23.                 System.Runtime.InteropServices.Marshal.ReleaseComObject(wordobject);
  24.                 txtwriteinenglish.Focus();
  25.  
Thanks in Advance.
Feb 11 '12 #1
1 2760
PsychoCoder
465 Expert Mod 256MB
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
Feb 11 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
1
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? --...
5
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...
3
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...
0
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...
2
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
0
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...
2
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...
0
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...
0
by: qfchen | last post by:
How should I set different font, size for each text word in the same rich-text-box window? thanks
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
tracyyun
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.