Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

Vb Tool

1) Can Someone please let me know how to convert word document into power point and vice versa using vb6.
2) Any idea how to make a vb tool to get the trace of your vb exe and related dll(like sql trace).it sould give the  trace of flow and tell clearly where application is failing(dll or exe).I have been ask to write such tool for one of my application as it keeps on failing and we always break our head to find out where its failing...
  • 2
1 Solution
First question:

Word and Powerpoint both have APIs that can be accessed from VB6. On a machine with VB6 and Office installed, create a new VB programme, and add references to "Microsoft Word 10.0 Object Library" and "Microsoft Powerpoint 10.0 Object Library". (That's how it looks on my system, but if you've got a different version of Office, the numbers will be different.)

Having done that, you can create or open up Word and Powerpoint documents and access the contents. A good starting point is to hit F2 and explore the methods you can call. The object model starts with "Application" in both cases. If you haven't got any experience with writing this kind of code, it's also very useful to practice writing macros in each application. Check out the Tools|Macro menu in Word and Powerpoint. The documentation is pretty good, but you'll need to spend a fair amount of time with it. The Microsoft Office website is also a very valuable resource, and you might even be able to download some sample code.

Second question:

The usual technique for this is to instrument the application itself by writing proper error handlers. If you write every method with its own error handler, the error handler can add information about the method to the error and then re-throw it. By the time the error reaches the "top" you have built an error stack that indicates exactly what went wrong. Of course, if your application doesn't have this already, it can be quite a lot of work, but you can get a lot of benefit just from adding very standard error handlers using some text processing tools to fix up the top and bottom of each method. Something like this

Sub Blah()
On Error Goto Handler
' You can also have a routine that outputs trace information to the system event log, a database,  a text file, or a debugger etc.
#If TRACE Then
    Call Trace("Start: Blah")
#End if

' method body here

Exit Sub
   ' re-raise will get err.description, add to it and then use that to call err.raise
   Call ReRaiseError(err, "Blah")

End Sub

End Sub
deepu712Author Commented:
Hi Domi,
             Appreciat your reply.
  First Question:
          I already tried this option, the main problem i am facing in copying from word to power point is
           how and when to insert a new power point slides(new page).
  Second Quesion:
          Dll has not been created by me and sadly my manager doesn't want me to write same dll
         (we dont have source)again,instead of that he wants me to find out some tools to track out the flow of
        the programe.
Recording a quick powerpoint macro gives:

ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=2, Layout:=ppLayoutText).SlideIndex

You might have to fiddle with it a bit, but that's how it's done. (You can probably miss out the GotoSlide part)

As for "when", that's trickier. If the Word documents are already laid out as slides, with suitable outlining and styles, then it should be reasonably straightforward. Otherwise, you'll have to come up with an algorithm based on the size of text etc. I'm actually having trouble trying to imagine what sort of documents you have to work with here. There aren't many kinds of word documents that it would make sense to convert to powerpoint.

As for the tracing issue. Firstly, what's the point? If you haven't got the source, what will you do if you *do* manage to find out where it's broken? Frankly, I would have to say that the best way to solve your problem is to educate your boss. There are very few options if you don't have the sources. Perhaps if there's an unhandled exception, you might be able to attach a debugger when it breaks, but that won't tell you much, except where in the dll or exe it's breaking.

Presumably if you haven't got the source, it's a dll made by someone else. The only people who can meaningfully do anything for you are the people who made it, and therefore have the source.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now