Macro For Stepping Into #import Wrapped COM Methods

When using #import to create wrapper classes for your own C++ COM objects, debugging and stepping into the COM methods can be tedious because you have to first step into the wrapper class and then COM object wrappers for many of the method's paramenters (e.g. _bstr_t and _variant_t), before you finally get to the raw method. To solve this I have written the macro StepInComFunc to do all the stepping in and out automatically for you, effectively stepping you directly into the source code for the method being called. Obviously the COM object will have to have been built with debug information. I find it useful to map this macro to the shortcut key ALT+F11.
Sub StepInComFunc()
'DESCRIPTION: A description was not provided.

 Application.Debugger.StepInto

 Dim nMaxParams, nCount
 nCount = 0
 nMaxParams = 20

 Do While ((ActiveDocument.Name = "COMUTIL.H" 
 Or ActiveDocument.Name = "ATLBASE.H") 
 And nCount < nMaxParams)

  Application.Debugger.StepOut
  Application.Debugger.StepInto
  nCount = nCount + 1
 Loop

 if (ActiveDocument.Name = "COMIP.H") then
  Application.Debugger.StepOut
  Application.Debugger.StepInto
 End If

 if (ActiveDocument.Name = "COMIP.H") then
  Application.Debugger.StepOut
  Application.Debugger.StepInto
 End If

 if (InStr(ActiveDocument.Name, ".tli") > 0) then
  Application.Debugger.StepOver
  Application.Debugger.StepInto
 End If

 nCount = 0
 Do While ((ActiveDocument.Name = "COMUTIL.H" 
 Or ActiveDocument.Name = "ATLBASE.H") 
 And nCount < nMaxParams)
  Application.Debugger.StepOut
  Application.Debugger.StepInto
  nCount = nCount + 1
 Loop

End Sub


Comments

  • That's is pretty cool!

    Posted by Legacy on 07/13/2001 12:00am

    Originally posted by: hn

    If you want to close those files as well, add ActiveDocument.Close

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: October 29, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this eSeminar, Gene Kim will discuss these survey findings and will share woeful tales of artifact management gone wrong! Gene will also share examples of how …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds