05-31-2018 10:43 AM
Would someone please help me with a script that will autosave the TDMS file to the same folder path that the csv file was opened in? I currently use the script below to select a folder however I would rather have it automatically store the TDMS with the csv and not ask for user input. The folder path to the csv will always vary so I can't set a specific path.
Call MsgboxDisp ("Please define a file location for the 'TDMS' file. The file name will be the same as the 'csv' file name.")
If "IDOk" = PathDlgShow ("Select folder to save TDMS output files", "C:\") Then
Call DataFileSave(OutPutPath&Data.Root.Name&".tdms","CSV")
End If
Thank you!
Solved! Go to Solution.
05-31-2018 10:59 AM
Hi Karen,
How do you load you CSV, manually or via script ?
Is your script in the same folder as the data ?
Thanks,
05-31-2018 11:02 AM
Hi, thanks for the quick response.
The csv file is loaded through a script with an interruption, see script below.
Call Data.Root.Clear
Call InteractionOn("1. Please load (drag) the data file into the Data Portal." & vbCRLF & vbCRLF & _
"2. Then click the button on the left to re-start the script.")
My script is not in the same folder as the data.
Thanks!
05-31-2018 11:22 AM - edited 05-31-2018 11:22 AM
Would something like this work for you ?
As you manually load the data, you can use the DataReadPath to get the path of the data you loaded 🙂
'------------------------------------------------------------------------------- '-- VBS script file '-- Created on 05/31/2018 11:17:50 '-- Author: '-- Comment: '------------------------------------------------------------------------------- Option Explicit 'Forces the explicit declaration of all the variables in a script. Call Data.Root.Clear Call WndShow("NAVIGATOR") Call InteractionOn("1. Please load (drag) the data file into the Data Portal." & vbCRLF & vbCRLF & _ "2. Then click the button on the left to re-start the script.") Call DataFileSave(DataReadPath & Data.Root.Name & ".tdms")
05-31-2018 11:36 AM
That works great!!!
Now it doesn't create my pdf report which was creating to the same directory as the data file. Can you help me modify this part of the script to create the report pdf and store it in the same folder?
' creates Report PDF
Dim PDFFile : PDFFile = OutPutPath&Data.Root.Name&".pdf"
'Dim PDFFile : PDFFile = LayoutWritePath & "Test Results.pdf"
Call Report.Sheets.ExportToPDF(PDFFile,False)
If (Err.Number <> 0) Then
Call MsgBoxDisp("Cannot create the PDF document.")
else
' show results in PDF reader
If FileExist(PDFFile) Then Call ExtProgram("", PDFFile)
If Err.Number <> 0 Then MsgBox "Cannot start the PDF Reader. Have you installed a PDF Reader on your computer?"
End If
05-31-2018 11:53 AM
05-31-2018 11:57 AM
Thanks very much for your help!
All works perfect!