Excel VBA and MS AMSI in Windows 10 - malicious macros detect

si3po

Board Regular
Joined
Jan 7, 2019
Messages
98
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi Folks,

i'm hoping somebody here might have come across this already and be able to help.

I'm using a new Windows 10 laptop issued to me by work to enable working from home. We use a multitude of spreadsheets, some with macros. Now, most of the macros work without hassle and do exactly what they're expected to do.

There is one macro (or maybe a handful all called by the one macro) that when run on Win10 within MS Office 365 ProPlus throws up this error:
1613733298001.png

Now, the macro isn't malicious in any way, indeed, I wrote it/them (with help from a few here actually) to automate a few processes within my WorkBook.

Is anybody able to throw a lifeline and suggest where i might find an answer? If it helps, i can post the entire macro(s) somewhere?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
***UPDATE!***

I've ran each macro step-by-step from within the VBA editor, and found that it triggered the AMSI error when running the following:

VBA Code:
Option Explicit
Option Private Module

Public Const GWL_STYLE = -16
Public Const WS_CAPTION = &HC00000
#If VBA7 Then
    Public Declare PtrSafe Function GetWindowLong _
                            Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

    Public Declare PtrSafe Function SetWindowLong _
                            Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Public Declare PtrSafe Function DrawMenuBar _
                            Lib "user32" (ByVal hWnd As Long) As Long

    Public Declare PtrSafe Function FindWindowA _
                            Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#Else
    Public Declare Function GetWindowLong _
                            Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

    Public Declare Function SetWindowLong _
                            Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Public Declare Function DrawMenuBar _
                            Lib "user32" (ByVal hWnd As Long) As Long

    Public Declare Function FindWindowA _
                           Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#End If
Sub HideTitleBar(frm As Object)
    Dim lngWindow As Long
    Dim lFrmHdl As Long
    lFrmHdl = FindWindowA(vbNullString, frm.Caption)
    lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
    lngWindow = lngWindow And (Not WS_CAPTION)
    Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
    Call DrawMenuBar(lFrmHdl)
End Sub

This, i believe, is the VBA triggered to display a UserForm progress bar... i copied it directly from instructions here: ufProgress Bar

Would there be anybody able to suggest an alternative method for this kind of progress bar similar to that in the instruction above.

many thanks in advance!
 
Upvote 0
Solution

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top