473,657 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embed in word

MRe
Hi,

Is there any way to write a graphical program in CSharp that could be
embedded into Word2000. I've read .NET doesn't support creation of ActiveX
controls (unless done using C++) but is there any other option, like an
existing ActiveX that can embed some CSharp program.

What I'd like to do is; whenever I'm writing an assignment for college, I
usually want to add some diagram that isn't easy to create with the tools
available to me, so I write a program to do it, take a snapshot, and put it
into the doc as a bitmap. However, when printing, the bitmap comes out
blurry, so if I could embed the program and send vector data to the printer,
that would be awesome!

Thanks for any help,
Kind regards,
Eliott
Jan 31 '07 #1
1 2624
You actually don't need to embed anything into word to accomplish the task
you have described. Just draw your graphics as vectors instead of bitmap and
no blurring will ocurr.

It's possible with GDI, but you'll need to apply a little hack:

using (Graphics g = this.CreateGrap hics()) //or Graphics from your paint
event
{
IntPtr dc = g.GetHdc();

using (Metafile metafile = new Metafile("foo.w mf", dc)) //your vector image
will be stored as foo.wmf
{
using (Graphics graphics = Graphics.FromIm age(metafile))
{
graphics.DrawEl lipse(Pens.Red, new Rectangle(0, 0, 50, 50));
//do your drawing here

//metafile.Save(" boo.wmf", ImageFormat.Wmf ); //I first guessed this
should allow you to save the image but this would throw a "generic error"
from GDI, so "foo.wmf" will be the only place where the image gets saved
}
}
}

Just insert the result (foo.wmf) into word as any other image - but you can
scale this one without any blur.

This is the only way I've found that seems to work. Plain image.Save(name ,
ImageFormats.Wm f) saves it as png, since there is no wmf encoder in GDI+.
This seems a little too hacky for me, but it works. If there's anyone who
knows how to save images as wmf in .NET in a "more straightforward way" I'd
be very glad to hear from him.

"MRe" <m.r.e.@.d.u.b. l.i.n...i.ewrot e in message
news:ut******** ******@TK2MSFTN GP03.phx.gbl...
Hi,

Is there any way to write a graphical program in CSharp that could be
embedded into Word2000. I've read .NET doesn't support creation of ActiveX
controls (unless done using C++) but is there any other option, like an
existing ActiveX that can embed some CSharp program.

What I'd like to do is; whenever I'm writing an assignment for college, I
usually want to add some diagram that isn't easy to create with the tools
available to me, so I write a program to do it, take a snapshot, and put
it into the doc as a bitmap. However, when printing, the bitmap comes out
blurry, so if I could embed the program and send vector data to the
printer, that would be awesome!

Thanks for any help,
Kind regards,
Eliott

Feb 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
4489
by: Anna | last post by:
Hi all. I want to embed the EMBED tag in the object tag. I understood that I need to provide a PARAM tag inside the OBJECT whose value will hold the content of EMBED src attribute, but after that I've got confused. For example, what should be put into classid and codebase attributes of the OBJECT now embedding the EMBED tag?
0
1760
by: beau | last post by:
Please help me ! Anybody can help me with a code to embed an ms word file into an access table ? I have ms word templates with bookmarks in my hard disk. So far I can open the template through a button in my access form, insert the bookmarks with data from the form and save the word document in the hard disk. I need to save/copy this document into a table as ole object, so the documents are kept within the recordset.
0
1999
by: beau | last post by:
Re. Embed or save ms word into OLE field Please help me ! Anybody can help me with a code to embed an ms word file into an access table ? I have ms word templates with bookmarks in my hard disk. So far I can open the template through a button in my access form, insert the bookmarks with data from the form and save the word document in the hard disk. I need to
0
4452
by: Mirco | last post by:
I can embed MS Word in my Windows form (either in the WebBrowser or in the DsoFrame ActiveX), I can show/hide toolbars with the ExecWB statement but I ABSOLUTELY CANNOT show Word's menu bar! The following property is true (!): oDocument.Application.CommandBars.Visible; Moreover, even if the menu bar doesn't show up when Word is embedded, if I try and float it with this code
1
3436
by: snicks | last post by:
I have a series of XLS files which I need to embed into a PowerPoint presentation on an IIS server. I’ll be using VB.NET. I’ve tried using an ASPOSE.PowerPoint control to do this and it does partially work. The problem is that when I embed the XLS files PowerPoint is not running and has no way of capturing the XLS image and embedding it into the PPT. When the user opens the PPT they are presented with hundreds of “Object...
5
5204
by: girishmat | last post by:
how to embed or open microsoft word file in a page using php script
13
3151
by: Lloyd Dupont | last post by:
In the good old days I believe people were using the arcane technology which came to be known as COM+ to embed other application's document in their own document. Like a Word with document a Windows Media Player or Excel or Visio document inside, double click on it and *bang* you coud start edit it using Excel/WMP/Visio toolbar. Apparently even OpenOffice could do that.
2
20185
by: henry1977PHP | last post by:
Hi, I really need help for this problem. I must generate a report as a word document and I also have to embed images(images also generated by php) into this word document so customer can download this word document into this own pc and still can see this images. Generating word document with php is not a problem. But i really get stuck with embedding images into word. I try many ways but they doen't work. And I google internet but cannot...
1
1521
by: oyster | last post by:
In my ms-word documnet, there are some calculation whihc I have to change due to different argumnet. is there any way to embed python code in word, so that I can write the following as a macro or something else, then the result (i.e. 2) is shown in the word documnet? def f(n): if n<2: return 1 else:
0
8407
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
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
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.