Hey guys.
I am tyring connect from my HMI (TP1200) to a network location and open a file from a folder. The twist is I don't know what the file name will be. I want to specify a folder and verify there is only one pdf in it and open that pdf.
If I specify the file I can open it no problem. I was hoping I could use some sort of wild card e.g. '*.pdf' but that would be to easy.
I also attempted to list the files in the directory but VBScript doesn't like using 'Scripting.FileSystemObject' or 'System.'
The above works. But I need to be able to 'not care' what the file name is since it will be different for each cell or potentially for different programs / models.
Can anyone recommend other commands / instructions to try?
I am tyring connect from my HMI (TP1200) to a network location and open a file from a folder. The twist is I don't know what the file name will be. I want to specify a folder and verify there is only one pdf in it and open that pdf.
If I specify the file I can open it no problem. I was hoping I could use some sort of wild card e.g. '*.pdf' but that would be to easy.
I also attempted to list the files in the directory but VBScript doesn't like using 'Scripting.FileSystemObject' or 'System.'
Code:
Sub VBFunction_1()
'Do not stop script if error
On Error Resume Next
'Open PDF instructions
Dim PDFViewer
Dim FileName
Dim FileLoc
Dim FullFileName
Dim ProgNum
'' Set program to open
PDFViewer = "\flash\AddOn\wt6explr.exe"
'' Set location of files
''FileLoc = "\Storage Card SD\"
FileLoc = "\\networkfolder\workinst\NCtest\AM\"
''FileName = "WorkInstructionsWI.pdf"
FileName = "*.pdf"
'' Set program number from HMI
ProgNum = SmartTags("ProgNum")
FullFileName = FileLoc + FileName
'' Open PDF instructions
StartProgram PDFViewer, FullFileName, hmiShowNormal, hmiNo
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
End Sub
Can anyone recommend other commands / instructions to try?