DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Script to autosave TDMS file to same folder as csv file

Solved!
Go to solution

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!

0 Kudos
Message 1 of 7
(3,008 Views)

Hi Karen,

 

How do you load you CSV, manually or via script ?

Is your script in the same folder as the data ?

 

Thanks,

CLAMaxime -- Kudos are a great way to say thank you
0 Kudos
Message 2 of 7
(3,003 Views)

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!

 

0 Kudos
Message 3 of 7
(3,001 Views)
Solution
Accepted by topic author KarenD

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")

 

 

CLAMaxime -- Kudos are a great way to say thank you
Message 4 of 7
(2,992 Views)

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

0 Kudos
Message 5 of 7
(2,986 Views)
I would just replace the OutPutPath variable with the DateReadPath if the Export happens after you load your data 🙂
CLAMaxime -- Kudos are a great way to say thank you
Message 6 of 7
(2,982 Views)

Thanks very much for your help! 

All works perfect!

0 Kudos
Message 7 of 7
(2,981 Views)