Rangraop
Automotive
- Mar 19, 2014
- 21
Hello Everybody,
This is very nice platform to share and enhance our knowledge. Only because of this site I could speed up my work.
I came with a query that, when we create a macro, can we create some code such that we will get know that, how many times our macro has been used. I believe based on this we could calculate how many man hrs we saved... so that we could present our achievement to management.
Any help on this would really be appreciated..
I have just taken a portion of code from cklong (Automotive) (OP)'s post
Does anybody know how to modify this code to use as catia macro.. I'm really weak in programming
**************************
Dim path As String
Dim filename As String
Dim scrpt As String
Dim objFSO, objReadFile, contents
Dim ccontents As String
On Error Resume Next
path = "c:\temp\" 'location of file
filename = "test.txt" 'add text name
scrpt = "test" 'name of macro
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFSO.OpenTextFile(path & filename, 1, False)
ccontents = objReadFile.ReadAll
If ccontents = "" Then
ccontents = 0
End If
ccontents = ccontents + 1
mut = Round(ccontents / 25)
If ccontents = 100 Then
MsgBox "You have use " & scrpt & " " & ccontents & "times you must really like this program."
ElseIf ccontents = 1 Then
MsgBox "Thank you for trying " & scrpt & " I hope you enjoy this program."
ElseIf ccontents = 25 * mut Then
MsgBox "You have use " & scrpt & " " & ccontents & "times. I think you owe me a coffee"
End If
Set Datos = CATIA.fileSystem.CreateFile(path & filename, True)
Set ostream = Datos.OpenAsTextStream("ForAppending")
ostream.Write ccontents & Chr(10)
ostream.Close
********************************
This is very nice platform to share and enhance our knowledge. Only because of this site I could speed up my work.
I came with a query that, when we create a macro, can we create some code such that we will get know that, how many times our macro has been used. I believe based on this we could calculate how many man hrs we saved... so that we could present our achievement to management.
Any help on this would really be appreciated..
I have just taken a portion of code from cklong (Automotive) (OP)'s post
Does anybody know how to modify this code to use as catia macro.. I'm really weak in programming
**************************
Dim path As String
Dim filename As String
Dim scrpt As String
Dim objFSO, objReadFile, contents
Dim ccontents As String
On Error Resume Next
path = "c:\temp\" 'location of file
filename = "test.txt" 'add text name
scrpt = "test" 'name of macro
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFSO.OpenTextFile(path & filename, 1, False)
ccontents = objReadFile.ReadAll
If ccontents = "" Then
ccontents = 0
End If
ccontents = ccontents + 1
mut = Round(ccontents / 25)
If ccontents = 100 Then
MsgBox "You have use " & scrpt & " " & ccontents & "times you must really like this program."
ElseIf ccontents = 1 Then
MsgBox "Thank you for trying " & scrpt & " I hope you enjoy this program."
ElseIf ccontents = 25 * mut Then
MsgBox "You have use " & scrpt & " " & ccontents & "times. I think you owe me a coffee"
End If
Set Datos = CATIA.fileSystem.CreateFile(path & filename, True)
Set ostream = Datos.OpenAsTextStream("ForAppending")
ostream.Write ccontents & Chr(10)
ostream.Close
********************************