?
Solved

Saving MS Word Equations to bitmaps from VB

Posted on 2003-03-05
4
Medium Priority
?
180 Views
Last Modified: 2010-04-07
I am looking to write a VB6 program to go through a Microsoft Word document, find all the equation editor objects, and save the equations as bitmaps. Does anyone know if or how i can do this? Thanks.
0
Comment
Question by:melancholyeel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8072943
Option Explicit
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Private Sub Form_Load()
Dim eq As InlineShape, i As Long
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open("c:\test_eq.doc")

For Each eq In WordDoc.InlineShapes
    eq.Select
    WordApp.Selection.CopyAsPicture
    pic1.Picture = Clipboard.GetData(vbCFBitmap)
    SavePicture pic1.Picture, "c:\eq" & i & ".bmp"
    i = i + 1
Next
WordDoc.Close (False)
WordApp.Quit
Set WordDoc = Nothing
Set WordApp = Nothing
End Sub
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 400 total points
ID: 8072956
or a more simple:

Option Explicit
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Private Sub Form_Load()
Dim eq As InlineShape, i As Long
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open("c:\test_eq.doc")

For Each eq In WordDoc.InlineShapes
    eq.Select
    WordApp.Selection.CopyAsPicture
    SavePicture Clipboard.GetData(vbCFBitmap), "c:\eq" & i & ".bmp"
    i = i + 1
Next
WordDoc.Close (False)
WordApp.Quit
Set WordDoc = Nothing
Set WordApp = Nothing
End Sub
0
 

Author Comment

by:melancholyeel
ID: 8074164
Thanks! It works great.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8074493
you are welcome. Thanks for "A" grade.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

764 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