Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default identifying files with macros

Hello all,

I'm not so familiar with Excel macro programming (as is perhaps evident
by my question).

Is there a way to determine which Excel files have macros?

The reason for this request is that our firewall/antivirus appears to
be rejecting emails that have Excel attachments - only certain ones,
though. I'm thinking that the reason some Excel files are being
rejected is because they have a macro (or macros).

Thanks for your input,
Emilio

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default identifying files with macros

Emilio,

I wrote this a while back as a catch all function for workbooks, sheets or
charts. I'd probably do it differently now, but it seems to work, so why fix
it.

To make it work, you need to have the Trust Access to VB Project option on
in your security settings.

Function fnContainsMacros(vSheetOrBook As Variant) As Variant
Dim W As Workbook
Dim S As Worksheet
Dim C As Chart
Dim T As Variant
Dim cmpComponent As VBComponent
On Error Resume Next
Set W = vSheetOrBook
Set S = vSheetOrBook
Set C = vSheetOrBook
On Error GoTo 0
fnContainsMacros = False
If W Is Nothing And S Is Nothing And C Is Nothing Then
fnContainsMacros = False
GoTo EndRoutine
End If
If W Is Nothing Then
If S Is Nothing Then
Set T = C
Else
Set T = S
End If
On Error GoTo VBAccessDisabled
With T.Parent.VBProject
If .VBComponents.Count 0 Then
On Error GoTo 0
For Each cmpComponent In .VBComponents
If cmpComponent.CodeModule = T.CodeName Then
If cmpComponent.CodeModule.COUNTOFLINES 0 Then
fnContainsMacros = True
GoTo EndRoutine
End If
End If
Next cmpComponent
End If
On Error GoTo 0
End With
Else
On Error GoTo VBAccessDisabled
If W.VBProject.VBComponents.Count 0 Then fnContainsMacros = True
On Error GoTo 0
End If
EndRoutine:
Set C = Nothing
Set W = Nothing
Set S = Nothing
Set T = Nothing
Exit Function
VBAccessDisabled:
Err.Clear
On Error GoTo 0
fnContainsMacros = "#N/A"
Resume EndRoutine
End Function

--
Robin Hammond
www.enhanceddatasystems.com


wrote in message
ps.com...
Hello all,

I'm not so familiar with Excel macro programming (as is perhaps evident
by my question).

Is there a way to determine which Excel files have macros?

The reason for this request is that our firewall/antivirus appears to
be rejecting emails that have Excel attachments - only certain ones,
though. I'm thinking that the reason some Excel files are being
rejected is because they have a macro (or macros).

Thanks for your input,
Emilio



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default identifying files with macros

Very easy.

First the Security Level to Medium:

Tools Macros Security

Then attempt to open any file and you will be warned if the file contains
macros.
--
Gary's Student


" wrote:

Hello all,

I'm not so familiar with Excel macro programming (as is perhaps evident
by my question).

Is there a way to determine which Excel files have macros?

The reason for this request is that our firewall/antivirus appears to
be rejecting emails that have Excel attachments - only certain ones,
though. I'm thinking that the reason some Excel files are being
rejected is because they have a macro (or macros).

Thanks for your input,
Emilio


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 329
Default identifying files with macros

Hi Emilio,

If your firewall/antivirus is rejecting *incoming* files with macros, then you're not going to be able to get around it with another
macro, since you can't test the file before your firewall/antivirus has had a go at it.

Cheers

--
macropod
[MVP - Microsoft Word]


wrote in message ps.com...
| Hello all,
|
| I'm not so familiar with Excel macro programming (as is perhaps evident
| by my question).
|
| Is there a way to determine which Excel files have macros?
|
| The reason for this request is that our firewall/antivirus appears to
| be rejecting emails that have Excel attachments - only certain ones,
| though. I'm thinking that the reason some Excel files are being
| rejected is because they have a macro (or macros).
|
| Thanks for your input,
| Emilio
|


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default identifying files with macros

Robin Hammond: That looks nicely thorough, but a bit more involved than
I had in mind.
Gary's student: I like your suggestion. Easy and straightforward.
macropod: You're right to a certain extent. If the file is zipped, it
is allowed in.

Thanks to all for your input.
Emilio



macropod wrote:
Hi Emilio,

If your firewall/antivirus is rejecting *incoming* files with macros, then you're not going to be able to get around it with another
macro, since you can't test the file before your firewall/antivirus has had a go at it.

Cheers

--
macropod
[MVP - Microsoft Word]


wrote in message ps.com...
| Hello all,
|
| I'm not so familiar with Excel macro programming (as is perhaps evident
| by my question).
|
| Is there a way to determine which Excel files have macros?
|
| The reason for this request is that our firewall/antivirus appears to
| be rejecting emails that have Excel attachments - only certain ones,
| though. I'm thinking that the reason some Excel files are being
| rejected is because they have a macro (or macros).
|
| Thanks for your input,
| Emilio
|


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros across multiple files peterhine21 Excel Programming 1 June 5th 06 09:34 AM
Pulling files in using Macros MSHO Excel Programming 5 January 11th 06 03:21 PM
Macros and different lengths of files Gretta Excel Worksheet Functions 1 January 26th 05 02:07 PM
Macros saving files. Tim P. Excel Programming 0 June 30th 04 04:34 PM
identifying shortcut keys associated with custom macros windsurferLA[_3_] Excel Programming 8 February 5th 04 12:57 PM


All times are GMT +1. The time now is 04:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"