473,396 Members | 1,712 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,396 software developers and data experts.

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 2607
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.CreateGraphics()) //or Graphics from your paint
event
{
IntPtr dc = g.GetHdc();

using (Metafile metafile = new Metafile("foo.wmf", dc)) //your vector image
will be stored as foo.wmf
{
using (Graphics graphics = Graphics.FromImage(metafile))
{
graphics.DrawEllipse(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.Wmf) 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.ewrote in message
news:ut**************@TK2MSFTNGP03.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
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...
0
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...
0
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...
0
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...
1
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...
5
by: girishmat | last post by:
how to embed or open microsoft word file in a page using php script
13
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...
2
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...
1
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.