Sunday, April 20, 2014
How to get Author details from Track Changes using VBA
If you want to know the details of track revisions, for example, Author name etc the following code will help you:
Sub Get_TrackRevision_Author()
Dim oRev As Revision
Dim oRange As Range
-----------------------------------------------------------
Change the line below to suit your needs
-----------------------------------------------------------
Set oRange = Selection.Range
-----------------------------------------------------------
Coded by Shasur for http://.blogspot.com
-----------------------------------------------------------
For Each oRev In oRange.Revisions
MsgBox oRev.Range.Text & " " & oRev.Author
Next oRev
End Sub
The following code provides you more information (like if the comment is inserted / deleted)
If oRev.Type = wdRevisionDelete Then
MsgBox oRev.Range.Text & " deleted by " & oRev.Author
ElseIf oRev.Type = wdRevisionInsert Then
MsgBox oRev.Range.Text & " added by " & oRev.Author
Else
MsgBox oRev.Range.Text & " " & oRev.Author
End If
If you want to know Date of Revision using VBA then the following can be added
MsgBox oRev.Range.Text & " " & oRev.Author & " " & oRev.Date
Friday, April 18, 2014
Using SUMPRODUCT to count
Lets look at the example below,
In column C dates and column D the error happened on the day with possible multiple entries.
Love to have your comments....
Thursday, April 17, 2014
Sort Columns of the Table using Word VBA
Sort Word Table columns using Word VBA
The following function uses Selection.Sort, you can try alternative methods if selection is not possible / permissible
Function SortTable()
ActiveDocument.Tables(1).Select()
Selection.Sort(ExcludeHeader:=True, FieldNumber:="Column 1", SortFieldType _
:=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending, FieldNumber2 _
:="", SortFieldType2:=wdSortFieldAlphanumeric, SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending, Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False, LanguageID _
:=wdEnglishUS)
Selection.MoveRight(Unit:=wdCharacter, Count:=1)
End Function
The above uses as three column table. Please customize it for your use
See also:
How to use .Net Array.Sort Function in VBA
Case in-sensitive comparison
Sunday, April 13, 2014
How to Convert Decimal to Hexadecimal using VBA
How to Convert Decimal to Octal using VBA
Sub Get_Hex_n_OCt_Values()
For i = 0 To 255
Debug.Print i & vbTab & Hex(i) & vbTab & Oct(i)
Next i
End Sub