Solved

View MS Word document on VB.NET

Posted on 2004-09-30
27
420 Views
Last Modified: 2009-07-29
 Hello experts!
  I'm developing a multi-choice application. The question is about Math. I can not type the formular directly in VB, so I use MS Word to type them (using MS Equation to type the Math). Now I want my users can view the document without the need that they have installed MS Office. Can this be done? And how? If you can give me an example, it's great!

  Waiting for your suggestions,
  Tri
0
Comment
Question by:dttri
  • 21
  • 6
27 Comments
 
LVL 3

Accepted Solution

by:
Arundel_Castle earned 400 total points
ID: 12190755
You can work with a word document in VB if you a have reference to the word object model. The object model I believe is only installed when you install Word. Would it not be simpler and more general to export you documents to HTML then they can run in a browser which is more widespread.
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12190810
Sorry its multipe choose questions as you said. This can be done in HTML with maybe a bit of DHTML. Its not difficult to learn and you can still create your documents in Word and save them as HTML. The word object model itself is complex and you would probably broaden your skills more by learning some HTML and DHTML. You could also moves these HTML pages onto an internet site and reach more people. Or if its local just post them on an Intranet site.
0
 
LVL 7

Author Comment

by:dttri
ID: 12197175
 Thanks Arundel,
  I've already known HTML. But the type of application I'm developing is about Math, so I don't know how to type the Math formula (some formula are very complex). That's why I choose Word for storing and displaying the questions and answers. Can you show me how to get it done in HTML?

  Tri
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12198743
If you have a word document you should be able to save it as HTML correct. Do your mathematical formula in word as you would normally do and then save the document as html.
This should give you what you need. Alternatively if you have a HTML development tool write you formula in word than see if it will cut and paste in. Do that and then get back to me.

0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12198745
If all goes well, alll I will have to do is add 4 check boxes and some java script on the client side.
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12200345
Just as a further note, I tried using the word document model in an app. When I started putting it on other users machine I started getting trouble. Think about the different versions of word that there is and service pack etz. I would have had a lot less trouble if I had a bit of ASP and HTML then. You can build simple client apps with HTML pages. Just put all the pages into a directory and have you links such as (Next question) reference another page in the same directory. You can also pass information such as score between the pages.
0
 
LVL 7

Author Comment

by:dttri
ID: 12201740
 Thanks Arundel very much,
  I have done my formula editing in Word and then save it as html and everything looks great! But I don't sure if it will display well on other machine. The html code I get is a bit litle complex:
[begin html code]
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="test_files/filelist.xml">
<link rel=Edit-Time-Data href="test_files/editdata.mso">
<link rel=OLE-Object-Data href="test_files/oledata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title> </title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>Photon</o:Author>
  <o:LastAuthor>Photon</o:LastAuthor>
  <o:Revision>1</o:Revision>
  <o:TotalTime>1</o:TotalTime>
  <o:Created>2004-10-01T16:40:00Z</o:Created>
  <o:LastSaved>2004-10-01T16:41:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Words>3</o:Words>
  <o:Characters>21</o:Characters>
  <o:Company>Photon Corp</o:Company>
  <o:Lines>1</o:Lines>
  <o:Paragraphs>1</o:Paragraphs>
  <o:CharactersWithSpaces>23</o:CharactersWithSpaces>
  <o:Version>10.3501</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:GrammarState>Clean</w:GrammarState>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
      {mso-style-parent:"";
      margin:0in;
      margin-bottom:.0001pt;
      mso-pagination:widow-orphan;
      font-size:12.0pt;
      font-family:"Times New Roman";
      mso-fareast-font-family:"Times New Roman";}
@page Section1
      {size:8.5in 11.0in;
      margin:1.0in 1.25in 1.0in 1.25in;
      mso-header-margin:.5in;
      mso-footer-margin:.5in;
      mso-paper-source:0;}
div.Section1
      {page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
      {mso-style-name:"Table Normal";
      mso-tstyle-rowband-size:0;
      mso-tstyle-colband-size:0;
      mso-style-noshow:yes;
      mso-style-parent:"";
      mso-padding-alt:0in 5.4pt 0in 5.4pt;
      mso-para-margin:0in;
      mso-para-margin-bottom:.0001pt;
      mso-pagination:widow-orphan;
      font-size:10.0pt;
      font-family:"Times New Roman";}
</style>
<![endif]-->
</head>

<body lang=EN-US style='tab-interval:.5in'>

<div class=Section1>

<p class=MsoNormal><sub><!--[if gte vml 1]><v:shapetype id="_x0000_t75"
 coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
 filled="f" stroked="f">
 <v:stroke joinstyle="miter"/>
 <v:formulas>
  <v:f eqn="if lineDrawn pixelLineWidth 0"/>
  <v:f eqn="sum @0 1 0"/>
  <v:f eqn="sum 0 0 @1"/>
  <v:f eqn="prod @2 1 2"/>
  <v:f eqn="prod @3 21600 pixelWidth"/>
  <v:f eqn="prod @3 21600 pixelHeight"/>
  <v:f eqn="sum @0 0 1"/>
  <v:f eqn="prod @6 1 2"/>
  <v:f eqn="prod @7 21600 pixelWidth"/>
  <v:f eqn="sum @8 21600 0"/>
  <v:f eqn="prod @7 21600 pixelHeight"/>
  <v:f eqn="sum @10 21600 0"/>
 </v:formulas>
 <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
 <o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:30pt;
 height:36.75pt' o:ole="">
 <v:imagedata src="test_files/image001.wmz" o:title=""/>
</v:shape><![endif]--><![if !vml]><img width=40 height=49
src="test_files/image002.gif" v:shapes="_x0000_i1025"><![endif]></sub><!--[if gte mso 9]><xml>
 <o:OLEObject Type="Embed" ProgID="Equation.3" ShapeID="_x0000_i1025"
  DrawAspect="Content" ObjectID="_1158179250">
 </o:OLEObject>
</xml><![endif]--></p>

</div>

</body>

</html>
[end html code]

  My question is: if my customer machine doesn't have Word installed or MS Equation installed, can it display the formula correct?

  Tri
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12201839
The HTML page or the browser don't have anything to do with word. The won't care if its installed or not. Thats the whole point of putting this into HTML to make it platform independant. The HTML might be complex but you have control over it and are not relying on some version of the word object model installed on someones machine.

One problem I see with the web page is this.

<meta http-equiv=Content-Type content="text/html; charset=windows-1252">

For this to be truly international (Some machines might not have charset=windows-1252) change this line to

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

This is telling the browers what encoding your using and it should not effect the page. Place in the above line and see what happens, then get back to me.
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12201900
I have tried it in my browser and am not getting anything showing.
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12201961
I don't think word is saving this file as HTML only.

<o:OLEObject Type="Embed" ProgID="Equation.3" ShapeID="_x0000_i1025"
  DrawAspect="Content" ObjectID="_1158179250"></o:OLEObject>

Is like a reference to an object.

Do you have a HTML development tool that you could cut and paste your math formula into.

0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12201987
I might need a little while to check this out. Thats definatley a referece to another program in the HTML and there is a load of XML there as well.
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12203001
The above is never going to run in a web browser because its got the equation object embeded in it.
I have been succeful with paste special and pasting the the formula out as an image into a drawing program.
There might be other ways I'll keep checking. Let me know what you think of the above.
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12203134
Theres also this.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
      <head>
            <title>myMath</title>
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
            <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
            <meta name="ProgId" content="VisualStudio.HTML">
            <meta name="Originator" content="Microsoft Visual Studio.NET 7.0">
      </head>
      <body>
            <math>
                  H(s) = &#8747;<sub>0</sub><sup>&#8734;</sup> e<sup>-st</sup> h(t) dt
            </math>
      </body>
</html>

If you put this into a notepad file save it as unicode.  It runs fine in my broswer.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12203147
Also this.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
      <head>
            <title>myMath</title>
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
            <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
            <meta name="ProgId" content="VisualStudio.HTML">
            <meta name="Originator" content="Microsoft Visual Studio.NET 7.0">
      </head>
      <body>
            <math>
                  H(s) = &#8747;<sub>0</sub><sup>&#8734;</sup> e<sup>-st</sup> h(t) dt
            </math>
            <p></p>
            <math>
                  C <box>dV<sub>out</sub><over>dt</box> = I<sub>b</sub>
                  &tanh;(<box>&#954;(V<sub>in</sub>-V<sub>out</sub>)<over>2</box>)
            </math>
      </body>
</html>

0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12203228
Heres the link that tells you all about using Mathematical symbols in HTML. Its not as straight forward as I would have thought. But sites like MathWorld use images. So it seems like the best option at the moment if you want to use mathematical symbols in a HTML pages for a multipule choice exercise.

http://www.cs.tut.fi/~jkorpela/math/
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12203249
By the way as well, its not word that you have to worry about if you want to go back to the orignial way you thought off. Its the Equation editor that would need to be installed on the users machine as well. Word only embeds an object from the equation editor. The equation editior is option on the office install as well so its doubtful a lot of users would have installed it. I still think the HTML with an image is your best option. Tell me what you think.
0
 
LVL 7

Author Comment

by:dttri
ID: 12206214
 Hello Arundel,
  When I type the formula in Word and save it as html, I noticed that Word save the html file with a folder. When I open the folder, I saw in it there is a image file that exactly like the formula! I think now I can use this image to display my formula. The image may be embeded as resource into my exe. Do you know any way to hide it from my end users? Because I don't want they edit my formula. Your help is very useful for me, thanks very much.

  Tri
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12206937
I see what you did to get the image. You cut and did a paste special back into word with the formula converted to an image.
Then save the file as HTML and word creates a folder to put the image in. Maybe be the best way to operate with this is with 2 word documents. In one word document you write your formulas with the equation builder and then cut and paste those formulas as images into the second document. That way you still have the original emded formula saved to another file, so if you need to change it or use it again you can. Always put the formula as an image into the HTML file, It will never work HTML with an embed formula object (Only on your computer maybe but not on another). After the formula is converted to an image to would be pretty hard to edit or change.
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12206972
Hiding it may be difficult acutally. You will end up with a lot of image files along with your HTML files. If your doing a group of HTML files that are connected to each other by links (This way you can give a series of question forwarding (DHTML) the persons score to a hidden text box in the next HTML file) , use a single directory below them, go into the HTML file and edit the src source path for the image. Its not as clean as I orginally would have thought it would be, I thought that a unicode based HTML page would have Math formula as character codes but it doesn't look straight forward enough with math formulas to do that, otherwise they would not be talking about special Math HTML tags.
       This (all HTML files only) way though its going to run on any platform that has a browser, PCs, Macs and Unix boxes even and you don't have to care about anthing thats installed on the platform (except for the browser of course but that is pretty general and wide spread on computers, I have never seen a computer without one).
       I haven't asked you whats this for, I have a passing interest in mathematics and thats why I was interested in the question (and the points of course thank you).
0
 
LVL 7

Author Comment

by:dttri
ID: 12209873
 Hello Arundel,
  The program is for student reviewing their understanding about Math.
  The program I will develop is using VB.NET, not php or asp so there is no browser related issue here. What I need now is hiding the image in my .exe so others can not tamper with it. Can you let me know how to do this?

  Thank for your help,
  Tri
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12210695
I don't know that you can hide image files. You still need the image file path in the HTML files.
0
 
LVL 7

Author Comment

by:dttri
ID: 12211169
 Oh, no, now we can forget the html. Because we already have the images for the formula, we don't need html anymore. We just use VB.NET to display the image. We can embed the image as resource, but the other users can edit the resource. So it's not a good idea. What do you think to make it better?
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12211562
One thing that springs to mind might be a small back end access database that holds your images. I know that you can store images in Access table fields. Once its in the database you can turn on Access security. Though this does not seem to be very straight forward either. I have found a control that is supposed to make things easier. See the the following links.

About storing picture data in databases

http://www.ammara.com/articles/imagesaccess.html

About the control
http://www.ammara.com/index.html
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12211651
I think I have found a way to just embed the images into your project.


http://www.vb-helper.com/howto_net_embedded_resources.html
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12211836
Hi I got the code working from the link above that should take care of things for you.

I had to declare picture_stream as System.IO.Stream, but other than that it worked fine. Follow the instructions in the link and make sure you set the Build Action property of the picture to "Embeded Resourse". I moved my exe out onto the desktop and it ran just fine.


Dim picture_stream As System.IO.Stream
        Dim bm As Bitmap

        picture_stream = _
            executing_assembly.GetManifestResourceStream(my_namespace _
            + ".Image4.jpg")
        If Not (picture_stream Is Nothing) Then
            bm = New Bitmap(picture_stream)
            PictureBox1.Image = bm
            picture_stream.Close()
        End If
0
 
LVL 3

Expert Comment

by:Arundel_Castle
ID: 12211892
By the way the image filename seems to be case sensitive. I put in ".image4.jpg" and got nothing, I had to use ".Image4.jpg" to make it work. Let me know that you have gotten this comment and haven't gone off and tried the database thing.
0
 
LVL 7

Author Comment

by:dttri
ID: 12212589
 Yeah, thank you very much Arundel. Your help is very useful for me.

  Tri
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now