Looking for some help to make message box disappear after a few seconds.
At the end of my script I would like the msgbox to show, but automatically close after 2 seconds without clicking the ok button.
I have changed my last line from a msgbox to a wscript popup to hopefully make it timeout after 2 seconds.
Here is the code:
Sub CATMain()
Dim doc1 as Document
Set doc1 = CATIA.ActiveDocument
Dim Choice As String
'display an input box asking for file name format choice
Choice = InputBox( "1 MyFile" & vbCrLf & "2 MyFile.CATPart" & vbCrLf & "3 C:\directory\MyFile.CATPart", "Choose 1, 2 or 3", "1")
If Choice = 1 then
'get base file name without extension
sString = CreateObject("scripting.filesystemobject").GetBaseName(doc1.FullName)
ElseIf Choice = 2 Then
'get Complete FileName
sString = CreateObject("scripting.filesystemobject").GetFilename(doc1.FullName)
Else
'get absolute path name and extension
sString = CreateObject("scripting.filesystemobject").GetAbsolutePathname(doc1.FullName)
End If
'copy variable to clipboard
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")
Set oWrite = oExec.stdIn
oWrite.WriteLine sString
oWrite.Close
'MsgBox sString, ,"text copied to ClipBoard"
CreateObject("WScript.Shell").Popup sString, 2,"text copied to ClipBoard"
End Sub
Thanks,
Rick
At the end of my script I would like the msgbox to show, but automatically close after 2 seconds without clicking the ok button.
I have changed my last line from a msgbox to a wscript popup to hopefully make it timeout after 2 seconds.
Here is the code:
Sub CATMain()
Dim doc1 as Document
Set doc1 = CATIA.ActiveDocument
Dim Choice As String
'display an input box asking for file name format choice
Choice = InputBox( "1 MyFile" & vbCrLf & "2 MyFile.CATPart" & vbCrLf & "3 C:\directory\MyFile.CATPart", "Choose 1, 2 or 3", "1")
If Choice = 1 then
'get base file name without extension
sString = CreateObject("scripting.filesystemobject").GetBaseName(doc1.FullName)
ElseIf Choice = 2 Then
'get Complete FileName
sString = CreateObject("scripting.filesystemobject").GetFilename(doc1.FullName)
Else
'get absolute path name and extension
sString = CreateObject("scripting.filesystemobject").GetAbsolutePathname(doc1.FullName)
End If
'copy variable to clipboard
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")
Set oWrite = oExec.stdIn
oWrite.WriteLine sString
oWrite.Close
'MsgBox sString, ,"text copied to ClipBoard"
CreateObject("WScript.Shell").Popup sString, 2,"text copied to ClipBoard"
End Sub
Thanks,
Rick