MS Office Warning (Some files can contain viruses)

QasimMGM

New Member
Joined
Nov 18, 2020
Messages
11
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi,
This is my second question in this great group,
every time I use VBA codes to open files in my laptop; I got a warning (attached).
is there any way to stop this warning?
 

Attachments

  • 1.png
    1.png
    7 KB · Views: 100

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
If you are sure that workbook is from trusted source as message says,
go to excel options, trust center and enable macro security option.
Every time you are not sure in the new opened workbook disable this option.
 
Upvote 0
If you are sure that workbook is from trusted source as message says,
go to excel options, trust center and enable macro security option.
Every time you are not sure in the new opened workbook disable this option.
Thank you for your response,
I did what in the image attached but it doesn't help
 

Attachments

  • 111.png
    111.png
    34.2 KB · Views: 40
Upvote 0
What code are you using to open the PDF files?
 
Upvote 0
What code are you using to open the PDF files?
VBA Code:
Sub FindRequest()
Dim i As String
i = Cells(ActiveCell.Row, 1).Text
ThisWorkbook.FollowHyperlink "D:\LAB\Tests\2020\Requests\E05-" + i + ".pdf"
End Sub
 
Upvote 0
Try this instead:

Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                                      (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
                                       ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_HIDE            As Long = 0&
Const SW_SHOW            As Long = 5&

Sub FindRequest()
Dim i As String
i = Cells(ActiveCell.Row, 1).Text
ShellExecute Application.hwnd, "Open", "D:\LAB\Tests\2020\Requests\E05-" + i + ".pdf", 0&, 0&, SW_SHOW 
End Sub
 
Upvote 0
Try this instead:

Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                                      (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
                                       ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_HIDE            As Long = 0&
Const SW_SHOW            As Long = 5&

Sub FindRequest()
Dim i As String
i = Cells(ActiveCell.Row, 1).Text
ShellExecute Application.hwnd, "Open", "D:\LAB\Tests\2020\Requests\E05-" + i + ".pdf", 0&, 0&, SW_SHOW
End Sub
I got this
 

Attachments

  • صور.jpg
    صور.jpg
    57 KB · Views: 41
Last edited:
Upvote 0
Since you have 64bit Office, you'll need:

Code:
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                                      (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _
                                       ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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