Sample chapter


There is now a sample chapter from our book available for free download. If you do not have the book, or just want a PDF version, you can download it here.


Comments (4)

  1. Dag Konig says:

    Interesting chapter. But it seams to be a couple of errors in one of your listnings. It is the one on page 107.

    On the first row I had to put DTE before ActiveDocument. This you have done on other code examples.

    I had also to change sp and ep from TextPoint to EditPoint, otherwize I don’t get the method Insert.

    Maybe it’s something that I had missunderstod?

    But beside of that I like it.

    I really want to do a marcro that can find pairs of strings. For example when I view a large HTML I want to highligt at <table> and find the end tag for it. That would be nice.

  2. Craig Skibo says:

    The DTE is optional depending on how you setup your macros environment. DTE is the appobject of the VS object model, and so it is implied. When you create a macro project, we create a hidden variable named DTE and set it to the VS object model. When you run a macro and a method or property call cannot be resolved it tries it with the app object variable infront of the expression, thus:

    MsgBox(ActiveDocument.Name)

    becomes

    MsgBox(DTE.ActiveDocument.Name)

    I am not sure why this is not working for you. I tried it a couple times and it worked for me. I thought that it could be one of the Option keywords (Option Explicit, Option Strict, etc.) were being used, but I could not get it to happen with those set (they only control variable declaration, but I thought there could be a chance). To be clear, the DTE. should be specified, and I will try to update that in the code for the book.

    The reason sp/ep works is because EditPoint is derived from TextPoint. CreateEditPoint returns an EditPoint, but since TextPoint is a base of EditPoint the implied case works correctly. Since TextPoint does not support the Insert method, you do not see it within statement completion, but because you are looking at the TextPoint interface of a EditPoint object, and since VB will do some late bound lookup on the object when trying to call methods or properties on an interface when the method/property is not on that interface, it works.

    I will send mail to Marc asking him to update these for any new releases we put out…

  3. Brian says:

    Hey, that was mine. I’ll be sure to update. Thanks for the feedback.

  4. JETYFY says:

    I really want to do a marcro that can find pairs of strings. For example when I view a large HTML I want to highligt at <table> and find the end tag for it. That would be nice.

Skip to main content