AJITH CHANDRAN
AJITH CHANDRAN

Reputation: 19

Check the MS office files(word, excel.ppt, access etc.) are macro enabled or not using javascript

I have some Office files... . I want to upload these files into Data Base... Before uploading i want to check the files are macro enabled or not... Expecting the solution in java script...

I have tried with the following file extensions..

".docm",".dotm",".xlm ",".xltm",".xlsm",".xla",".xlam",".pptm",".potm",".ppsm",".sldm",".ppam",".accde"

but i need to know any other way to find the solution in JS or C#,

by processing the file content and check any programming contents inside it..

these are the codes i tried...

var extnsnArray=[".docm",".dotm",".xlm",".xltm",".xlsm",".xla",".xlam",".pptm",".potm",".ppsm",".sldm",".ppam",".accde"]

var extnsn = $(file).attr('extension');

if (extnsnArray.indexOf(extnsn) > -1) 
{                                      
    // file is macro enabled                        
}                                       
else
{                                                                                   
   // file is not macro enabled                           
}                                        

Upvotes: 2

Views: 502

Answers (1)

Steve Rindsberg
Steve Rindsberg

Reputation: 14809

In the case of PowerPoint, any PPTM, PPSM, POTM, PPAM file either contains macros or is some other type of file that's been given the wrong extension, in which case PowerPoint won't open it.

PPT files may or may not contain macros, making things more complicated if you need to look at them.

Upvotes: 1

Related Questions