Skip to main content

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

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


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


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


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


@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.


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

 


How does this look at your end?:

 


Hi Hans,

This is my Document Macro

 

Regards


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

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


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


Hi Hans,


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

 

Regards

 

 


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


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


Hi,

 

Regards


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?


Hi @Mathias Dahl ,

 

Need you input in this issue

 

Regards


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.


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.

 


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


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