We help IT Professionals succeed at work.

Converting a Word Document to a BMP file

I have a very peculiar requirement. I have to convert a MsWord document to a BMP file.  The word document has text as well as image in it (signature in bmp format).

Could anyone help me to do this please. This is very urgent.

Thanks
Prakash
Comment
Watch Question

Commented:
Open two instances of MSPAINT.

Open MSWord.

Assuming the document is one page, view the top half of the document and hit the PrintScreen key (usually in the upper-right area of the keyboard to the left of the Scroll Lock key).

Go to one of the MSPAINT sessions, and hit Ctrl-V, or click Edit => Paste.  The top half of the document should appear there.

Go back to the MSWord window and view the bottom half of the document.  Hit the PrintScreen key.

Go to the second MSPAINT session and paste the image.  Then, use the selection tool to highlight the bottom half of the document (basically, where the top of the document ends, the bottom of the document begins).

Click on Edit => Copy to copy the highlighted portion of the bottom of the doc.  Then, Paste that selection into the first MSPAINT session.

Slide the second part of the doc until the entire doc is visible on the screen.  Then, use the selection tool to highlight the document, and click Edit => Copy.

Click File => New in MSPAINT to open a new image.  Click Paste to paste the document.  Click File => Save As, and save the document as a 16-color BMP file.
Brendt HessSenior DBA
BRONZE EXPERT

Commented:
There are printer drivers out there for Windows that will print to BMP.  If this is a one-time thing, you can use one of their free trial installs.  If it will be ongoing, I believe that the commercial programs will be most efficient for this.

http://www.peernet.com/drivers/F._BMP_Driver.html
Demo available
1 end user license: $59.95
Developer kit (redistributable with your program) available.

http://www.informatik.com/tiffwork.html

Designed for printing to TIFF files, but has an add-on for printing BMPs.
Demo Available
1 User $70.00
Does not appear to have a re-distributable version.
ping

Commented:
hi pakku,

the brute force way would be to print out each page and then scan the pages with your scanner and save as .BMP..
usually the default file type..also you could save each page as .jpg  for much smaller file size and easy to send over the internet.  also you can check and modify the layout of each page and modify, if required for the final scan and .BMP file for your requirement.

sincerely

leo
Richie_SimonettiIT Operations
BRONZE EXPERT

Commented:
Dim WordApp As Word.Application
Dim WordDoc As Word.Document



Private Sub Form_Click()
Dim rng As Range
Set rng = WordDoc.Content
With rng
   .WholeStory
   .CopyAsPicture
End With

Picture1.PaintPicture Clipboard.GetData(vbCFEMetafile), 0, 0, , , , , , vbMergePaint
SavePicture Picture1.Image, "E:\VB Proj\Doc to bmp\doctobmp.bmp"
End Sub

Private Sub Form_Load()
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open("E:\VB Proj\Doc to bmp\doctobmp.doc")
WordApp.Visible = True
End Sub
Richie_SimonettiIT Operations
BRONZE EXPERT

Commented:
Using BMP files has its penalties.
Even a little word document could expand to several KB.
By the way, any progress with this matter?
Richie_SimonettiIT Operations
BRONZE EXPERT

Commented:
NOte: Set Autoredraw and autosize properties to true for picture1 control.
Cheers
IT Operations
BRONZE EXPERT
Commented:
Last minute change:
'there was a problem when word document was greather than picture size. Solved :)

Dim WordApp As Word.Application
Dim WordDoc As Word.Document




Private Sub Command1_Click()
Dim rng As Range
Set rng = WordDoc.Content
With rng
  .WholeStory
  .CopyAsPicture
End With
Dim sPic As StdPicture
Dim lWidth As Long, lHeight As Long
Set sPic = Clipboard.GetData(vbCFEMetafile)

lWidth = ScaleX(sPic.Width, vbHimetric, vbPixels) \ 1
lHeight = ScaleY(sPic.Height, vbHimetric, vbPixels) \ 1
With Picture1
    .Width = lWidth
    .Height = lHeight
    .PaintPicture sPic, 0, 0, , , , , , vbSrcCopy 'vbMergePaint
    SavePicture Picture1.Image, "C:\A_Project\Doc to bmp\doctobmp.bmp"
End With
End Sub

Private Sub Form_Load()
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open("C:\A_Project\Doc to bmp\mydoc.doc")
WordApp.Visible = True
End Sub


Private Sub Form_Unload(Cancel As Integer)
WordApp.Quit
End Sub

Author

Commented:
Thanks Zoplax.
I am sorry. But my question was related to Word macro programming. I should have mentioned in my question. Sorry about that.

Thanks anyway.
Pakku

Author

Commented:
Thanks bhess1,

Your answer was one of the closest.  
The first link you mentioned, I tried. But the developers kit is too expensive. So I had to drop it.  I could not try the second link. Sorry about that.

Thanks anyway.

Author

Commented:
Thanks leo. But I am sorry that my question is word macro programming related.

Author

Commented:
Thanks Ritchi.  You answer is the closest and I had already tried it Except I did not try the vbCFEMetafile while getting data from the clip board.

I have two questions. My word document has a digital signature and regular word contents. Will your program work. I will be trying it tomorrow. I shall get back to you on that after that. As of now I think that the points belong to you.

Second is what happens if my word document has 10 pages.
Just curious.

Pakku

Author

Commented:
Ritchi,

I could do this program using a very little known ActiveX control called Kodak Image Control in a word macro. I would admit that yours is the simplest solution.

Thanks
Prakash.
Richie_SimonettiIT Operations
BRONZE EXPERT

Commented:
Thanks. If your doc has several pages, it would be a bmp of several MB in size.
BMP is not the best way to store a picture.

Author

Commented:
Richie,

Your solution worked. Thanks for your help. The points are yours.

I agree with what are your saying about the size. But unfortunately I am trying to integrate my program with an existing product that takes data either in text format or BMP format.

Since the word document has electronic digital signature in it, I have to store it as BMP. I dont have a choice.

With your program, the bmp file size of a single page signed word document is 1.8MB.  But with Kodak control and a complex programming logic I could bring down the size to around 900 KB. Well, the BMP is stored as a 256 color bitmap not 24 bit.

I would vote for your solution as it simple and elegant.

Thanks once again.
Prakash
Richie_SimonettiIT Operations
BRONZE EXPERT

Commented:
Thanks. I have been working hard to find the solution. Surely, you don't want to know about my experiments, really.
Richie_SimonettiIT Operations
BRONZE EXPERT

Commented:
How much color depth do you need?, it could be monochrome?

Author

Commented:
256 Colors is enough.
Richie_SimonettiIT Operations
BRONZE EXPERT

Commented:

Explore More ContentExplore courses, solutions, and other research materials related to this topic.