473,549 Members | 2,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 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
Feb 11 '12 #2

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

Similar topics

1
2260
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...
1
1150
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
5
8270
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 = ""
3
2173
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...
0
2404
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...
2
1577
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
887
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...
2
5541
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.
0
2047
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.
0
1302
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
7542
marktang
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...
0
7467
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...
0
7736
Oralloy
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. ...
1
7500
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...
0
7827
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 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...
0
3494
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1961
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
1
1079
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
783
bsmnconsultancy
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...

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.