Question

Document Management file size for word and mp4 document


Userlevel 3
Badge +8
  • Do Gooder (Customer)
  • 42 replies

Dear All,

I am working on same kind of requirement to restrict a word document 1 MB, before Check-in in document management and I need your help on it.

I also find this Macro on community but not working might be some configuration issue.

Public Sub SizeCheck ()

  Const maxFileSize = 1024

  strFile = ClientScriptValues.Item('WORD').Value

  Set objFSO = CreateObject("Scripting.FileSystemObject")

  Set objFile = objFSO.GetFile(strFile)

  If objFile.Size > maxFileSize Then

    Err.Raise 1000, "File size check", "File is larger (" & objFile.Size & ") than the maximum specified file size (" & maxFileSize & "). Try again and select a smaller file."

  End If

End Sub

 

 

Regards


This topic has been closed for comments

20 replies

Userlevel 7
Badge +30

ClientScriptValues.Item('WORD').Value looks strange. Did you read the documentation on macros and what client script values are available?

Userlevel 3
Badge +8

Hi Mathias,

I have test but still unable to restrict document before check in

 

Public Sub SizeCheck ()

  Const maxFileSize = 100

    strFile = ClientScriptValues.Item("LOCAL_FILE_1").Value

  Set objFSO = CreateObject("Scripting.FileSystemObject")

  Set objFile = objFSO.GetFile(strFile)

  If objFile.Size > maxFileSize Then

    Err.Raise 100, "File size check", "File is larger (" & objFile.Size & ") than the maximum specified file size (" & maxFileSize & "). Try again and select a smaller file."

  End If

End Sub

 

 

Regards

Userlevel 7
Badge +30

Have you made sure that the macro is running? Do you get any error?

Userlevel 3
Badge +8

Hi Mathias,

 

That is the main issue there is no error promoting and i am unable to understand, Might be i am missing some steps, Can you share the steps so that i will follow accordingly

 

Regards

Userlevel 6
Badge +14

@WSHAH ,

First you have to make sure that your macro is running. Try this:

 

Public Sub SizeCheck ()

  Const maxFileSize = 100

    strFile = ClientScriptValues.Item("LOCAL_FILE_1").Value

  Set objFSO = CreateObject("Scripting.FileSystemObject")

  Set objFile = objFSO.GetFile(strFile)

 

    Err.Raise 100, "File size check", "File is larger (" & objFile.Size & ") than the maximum specified file size (" & maxFileSize & "). Try again and select a smaller file."

 

End Sub

 

It will force an error. If you do not get any, the macro is not running.

Userlevel 3
Badge +8

Hi Hans,

No error prompt after modifying Macro, I have import a word file with size 1.2 MB , Macro is unable to stop it. Seems that Macro is not working.

Regards

 

Userlevel 6
Badge +14

How does this look at your end?:

 

Userlevel 3
Badge +8

Hi Hans,

This is my Document Macro

 

Regards

Userlevel 6
Badge +14

This looks ok, except you do not have a ‘Timeout’. 

The Filetype also have to refer to a doc or docx extention.

Userlevel 6
Badge +14

ohh, you have SizeCheck as Action. That is wrong. Try with ‘SelectAndRun’ or look up in the documentation for alternatives.

Userlevel 3
Badge +8

Hi Hans,


File Type    File Extension    Description        Document Type
WORD        DOC            Word Document        ORIGINAL

 

Regards

 

 

Userlevel 3
Badge +8

Hi Hans,

 

I have modified but still no action


Document Macros

File Type= WORD
Script Language=VBScript
Process=CHECKIN
Action=SelectAndRun
Main-Function=SizeCheck
Description=Checkin Word Doc
Blockname=SizeCheck

Document Macro Blocks
Blockname=SizeCheck
Script=

Public Sub SizeCheck ()
  Const maxFileSize = 100
    strFile = ClientScriptValues.Item("LOCAL_FILE_1").Value
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.GetFile(strFile)
    Err.Raise 100, "File size check", "File is larger (" & objFile.Size & ") than the maximum specified file size (" & maxFileSize & "). Try again and select a smaller file."
End Sub

 

Regards

Userlevel 6
Badge +14

Is the word document youare checking in a .docx instead of .doc?

Userlevel 3
Badge +8

Hi,

 

Regards

Userlevel 6
Badge +14

This is getting strange now. The macro is working here, with a doc extension. 

The only other option I can think of, is that you checkin more than 1 file. That will prevent the macro from running.  

Maybe, @Mathias Dahl has some ideas?

Userlevel 3
Badge +8

Hi @Mathias Dahl ,

 

Need you input in this issue

 

Regards

Userlevel 7
Badge +30

ohh, you have SizeCheck as Action. That is wrong. Try with ‘SelectAndRun’ or look up in the documentation for alternatives.

FYI, the Action field has no functional effect on macros. It is just needed to make multiple macros for the same file type and process unique. You are mixing this up with the Select And Run option in the Document Class Process Action configuration.

Userlevel 7
Badge +30

Have you read the documentation on how macros work? It contains a lot of details on how to get macros to run, the process of configuring them, etc.

I recommend you just try this simple macro (a similar one can be found in the documentation):

Public Sub SizeCheck ()

  MsgBox "This is a macro"

End Sub

to make sure it runs at all. Even the simple “error macro” suggested by Hans can fail.

My guess is that macros does not run, for some reason. The documentation should have all clues about that.

 

Userlevel 3
Badge +8

Hi,

 

Yes Simple Macro is also not running, for some reason but unable to find issue in document kindly suggest the document or dtep to check why Macro is not running or how we can run a Macro.

Example of a Macro

This is an example of a macro that causes a message box to open when the connected process is performed.

Macro block MESSAGEBOXTEST:

Public Sub MessageBoxTest()

MsgBox "This is a very simple macro."

End Sub

 

https://docs.ifs.com/ifsclouddocs/default.htm?openpage=https://docs.ifs.com/ifsclouddocs/CreateAndMaintainDocument/ActivityDefineObjectAttributesForMacros.htm

I have followed the document but all in vain right now.

 

Regards

Userlevel 7
Badge +30

That document is related to Docman macros, but more of advanced topic. 

You should read this document from the start to the end. Carefully and several times :-)

https://docs.ifs.com/ifsclouddocs/CreateAndMaintainDocument/AboutDocumentMacro.htm?StandAlone=true