title: Antivirus False positive in my VBA Excel Macro
body: <p>I just ran into an <a href="https://stackoverflow.com/questions/3339136/antivirus-false-positive-in-my-executable">even more annoying problem</a>. Suddenly windows defender started to flag one of my excel files containing VBA macro code(on download from a browser) as being a virus. The specific virus being logged is:</p>
  
  <blockquote>
    <p><a href="https://www.microsoft.com/en-us/wdsi/threats/malware-encyclopedia-description?name=Trojan%3AO97M%2FForetype.A!ml&amp;threatid=2147724333&amp;enterprise=1" rel="noreferrer">Trojan:O97M/Foretype.A!ml</a></p>
  </blockquote>
  
  <p>Googling it reveals the following information: </p>
  
  <blockquote>
    <p><a href="https://www.symantec.com/security-center/writeup/2015-031222-2047-99" rel="noreferrer">O97M.Downloader is a generic detection for Microsoft Office macros
    that download other threats. They are usually contained in other
    Microsoft Office documents and may arrive on the compromised computer
    through attachments or after being downloaded from a website.</a></p>
  </blockquote>
  
  <p>Great, so once windows defender detects it, it basically shreds the file, and when you attempt to open it, excel claims the file has "been corrupted". I would love to post my VBA file to <a href="http://www.virustotal.com" rel="noreferrer">http://www.virustotal.com</a> however it contains tons of propriety VBA code that cannot be shared with the wider community. I wonder if there's a website that accomplishes the same thing with a different terms and conditions?</p>
  
  <p>This has only started recently and has only affected a few users/clients. I'm not sure the distribution of clients who have this installed and what versions of windows defender they are running. I'm worried the impact of this will increase until a large number of our clients are affected. Even more troubling, often clients can download one version without issue, but when they download the file(identical VBA code) from a different source they encounter the issue, could the download source affect the files likelihood of being flagged?</p>
  
  <p><strong>Main Question</strong></p>
  
  <p>What causes a excel VBA file to be flagged as a "O97M" virus and how do I prevent it from being flagged?</p>
  
  <p><strong>Related Concerns</strong></p>
  
  <p>Should <a href="https://support.office.com/en-us/article/digitally-sign-your-macro-project-956e9cc8-bbf6-4365-8bfa-98505ecd1c01" rel="noreferrer">I sign my VBA Macro's</a>, would that affect the virus detection likelihood? </p>
  
  <p>Are they're other common practices that I could change that would affect the likelihood of false positives?</p>
  
  <p>What is a "Trojan:O97M/Foretype.A!ml" exactly? The window page contains so little information it might as well not exists, Symantec is also pretty unhelpful, (maybe I'm massively uninformed here) is there a centralized repository for virus detection? I would imagine that people may not want to share that and it my differ by product, but I'd be interested in any information pertaining to this...</p>
  
  <p><strong>External Libraries</strong></p>
  
  <p>I'm also using the following external code: </p>
  
  <blockquote>
    <p><a href="https://gist.github.com/brucemcpherson/3414365/" rel="noreferrer">https://gist.github.com/brucemcpherson/3414365/</a></p>
    
    <p><a href="https://www.thespreadsheetguru.com/the-code-vault/2014/4/23/loop-through-all-excel-files-in-a-given-folder" rel="noreferrer">https://www.thespreadsheetguru.com/the-code-vault/2014/4/23/loop-through-all-excel-files-in-a-given-folder</a></p>
    
    <p><a href="https://stackoverflow.com/questions/18899824/how-to-use-vba-saveas-without-closing-calling-workbook/18901568#18901568">How to use VBA SaveAs without closing calling workbook?</a></p>
  </blockquote>
  
  <p>I'm also using the following window functions:</p>
  
  <pre><code>Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
  Public Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As LongPtr, ByVal nIndex As Long) As LongPtr
  Public Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
  Public Declare PtrSafe Function GetWindowRect Lib "user32" (ByVal hWnd As LongPtr, lpRect As RECT) As LongPtr
  Public Declare PtrSafe Function SetWindowPos Lib "user32" (ByVal hWnd As LongPtr, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongPtr
  Public Declare PtrSafe Function SetParent Lib "user32.dll" (ByVal hWndChild As LongPtr, ByVal hWndNewParent As LongPtr) As LongPtr
  Public Declare PtrSafe Function SetForegroundWindow Lib "user32" (ByVal hWnd As LongPtr) As LongPtr
  Public Declare PtrSafe Function GetDeviceCaps Lib "gdi32.dll" (ByVal hdc As LongPtr, ByVal nIndex As LongPtr) As LongPtr
  Public Declare PtrSafe Function GetDC Lib "user32.dll" (ByVal hWnd As LongPtr) As LongPtr
  Public Declare PtrSafe Function ReleaseDC Lib "user32.dll" (ByVal hWnd As LongPtr, ByVal hdc As LongPtr) As LongPtr
  Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  Public Declare PtrSafe Function SetLastError Lib "kernel32.dll" (ByVal dwErrCode As Long) As Long
  Public Declare PtrSafe Function GetActiveWindow Lib "user32.dll" () As Long
  Public Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As LongPtr) As Long
  </code></pre>