06-26-2012 08:01 AM
Hello,
I am trying to export to pdf without dialog but want the pdf to go to a file path that exists in the file properties of the TDMS data set that is loaded. I have also wrote it as a channel as well. I cannot get this to work.
' create PDF
Dim
PDFFile : PDFFile = ch([1]/SI PDF Path)
PrintLeftMarg
= 0.23
PrintTopMarg
= 0.23
PrintWidth
= 8
PrintOrient
= "portrait"
On
ErrorResumeNext
Call
PicPDFExport(PDFFile)
If
(Err.Number <> 0) Then
CallMsgBoxDisp("Cannot create the PDF document.")
else
' show results in PDF reader
IfFileExist(PDFFile) ThenCallExtProgram("", PDFFile)
IfErr.Number <> 0ThenMsgBox"Cannot start the PDF Reader. Have you installed a PDF Reader on your computer."
End
If
Err
.Clear
On
ErrorGoto0
Solved! Go to Solution.
06-26-2012 08:21 AM
You can find the path with the following property
Data.Root.ChannelGroups(1).Channels(1).Properties("sourcedatafilepath").Value
To get this line you can drag&drop the property from the DataPortal into the workspace of SCRIPT.
I hope this helps
Winfried
06-26-2012 08:27 AM
I have tried dragging from the properties which gives me
Data.Root.Properties("SI_PDF_Path").Value
And dragging the channel gives me
Data.Root.ChannelGroups(1).Channels("SI PDF Path")
Both do not work for me.
06-26-2012 08:39 AM
The following line does not contain any channelname and works if you have at least one channel. It returns the path of the first channel in the first group:
Data.Root.ChannelGroups(1).Channels(1).Properties("sourcedatafilepath").Value
Winfried
06-26-2012 08:48 AM
Thanks for helping me.
I am sorry if i am not understanding this but I know the path to my data channel ([1]/ SI PDF Path). I want to get this channels value (which is a string- C:\Data\Name of file) and set it equal to PDFFile in the above script.
If I use PDFFile= ch("[1]/SI PDF Path") - my result path is the numeric data index of the group and not the string value. I suppose because I got this from the calculator. But it is the only thing that remotely works for me.
06-26-2012 09:04 AM
I am still not sure if I understand you. You store the filepath in the first value of the channel "[1]/ SI PDF Path"
To get this value use:
Data.Root.ChannelGroups(1).Channels("SI PDF Path").Values(1)
But why do you store the path as channel value? There are default properties that contains the path.
Hope this helps
Winfried
06-26-2012 09:43 AM
I am storing the filepath that i want the pdf to be exported to. I have wrote this path as both a channel (called SI PDF Path) and a file property. The channel has one value - the path to export the pdf document to.
06-26-2012 12:32 PM
I finally figured it out.
The script should look like:
Dim PDFFile
PDFFile = Data.Root.Properties("SAE_PDF_Path").Value
The colon was screwing it up and moving it to the second line.