TIA / WinCC Flex VBScript open file

JOLTRON

Lifetime Supporting Member
Join Date
Aug 2006
Location
MI
Posts
692
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.'




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
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 guess no body has any experience with this :(

I am still not having any luck with this.
 

Similar Topics

I am unable to enter an MW tag into the WinCC Flex portion of TIA portal:mad:. I can enter a memory bit us %M20.0 for example. But it gives me a...
Replies
2
Views
5,251
In our production plant we have multiple different networks (subnets). IT dept have setup routing between them so different subnets can...
Replies
0
Views
49
I created a project with Tia portal wincc runtime advanced PC station and also activated its smartserver for some smartclients to connect to it...
Replies
1
Views
271
Hello, just started my first project with a unified HMI. I want to use an image as background, how is this accomplished?
Replies
1
Views
453
Hi all, I really need help with this one. I'm at a complete loss... For months and months, I've had no problems with pressing a NEXT button to...
Replies
14
Views
1,385
Back
Top Bottom