Have you learned the trick of creating a macro in a couple of minutes to do some repetitive task, even if you only use the macro once? This article will hopefully cause you to remember the power of macros so that you will get in the habit of thinking of them as a way to consistently save time in making code modifications.
This week, I had the following code already written.
| With RequestData.edInfo1 xtw.WriteStartElement("EDUCATION_INFO") If .Institution.Length > 0 Then xtw.WriteAttributeString("INSTITUTION", .Institution) End If xtw.WriteAttributeString("INSTUTITION_TYPE", .Institution_Type) xtw.WriteAttributeString("CITY", .City) xtw.WriteAttributeString("STATE", .State) xtw.WriteAttributeString("COUNTRY", .Country) xtw.WriteAttributeString("PHONE_NBR", .Phone_Nbr) xtw.WriteAttributeString("FROM_DATE", .From_Date) xtw.WriteAttributeString("TO_DATE", .To_Date) xtw.WriteAttributeString("GRADUATED", .Graduated) xtw.WriteAttributeString("DEGREE", .Degree) xtw.WriteAttributeString("MAJOR", .Major) xtw.WriteAttributeString("MINOR", .Minor) xtw.WriteAttributeString("NAME_ATTENDED_UNDER", .Name_Attended_Under) xtw.WriteAttributeString("REQUESTER_REFERENCE", .Requester_Reference) xtw.WriteEndElement() End With |
| Public Sub AQuikWrapIF() Dim ts As TextSelection = DTE.ActiveDocument.Selection Dim s As String = ts.Text ts.StartOfLine() ts.LineDown(True) Dim s2 As String = " If " & s & ".Length > 0 Then" & vbCrLf s2 &= ts.Text s2 &= " End If" & vbCrLf ts.Delete() ts.StartOfLine() ts.Insert(s2) End Sub |
| Ask a Question, or give your feedback on my articles or products by going to the KnowDotNet Forum or by clicking on My Blog. | ![]() |