Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can excel macros be converted into diadem

87 views
Skip to first unread message

Stagsden

unread,
Jul 23, 2008, 7:40:08 AM7/23/08
to
From the standard csv format which I can get from Diadem, I would like to change headers and put in another column of data.
I can do this within Excel easily enough mannually or by using a macro, but I would like to be able to import the macro VB script from Excel into Diadem.
 
In which case I would not need to open Excel and I my edited csv file is ready to use.
 
The attached file just contains the first few data points
 
Regards
 
Stagsden


excel_macro_csv_format.ZIP:
http://forums.ni.com/attachments/ni/60/9080/1/excel_macro_csv_format.ZIP

Brad Turpin

unread,
Jul 23, 2008, 5:40:12 PM7/23/08
to
Hi stagsden,
 
I have looked at your two CSV files, and I see the difference in both columns and header rows.  What I'm not clear on is whether these CSV files should be read into DIAdem or exported from DIAdem.  If you want to read the CSV files into DIAdem, then you need a new DataPlugin to do that.  If you want to export the CSV file from DIAdem, then where iin the Data Poral is the new information to be stored in the new header rows?  In properties?  In channel values?  Can you send me a TDM and TDX file of the data as it appears in your Data Portal prior to the export?  Also, by what formula should the new column(s) be calculated?
 
Brad TurpinDIAdem Product Support EngineerNational Instruments

Stagsden

unread,
Jul 24, 2008, 5:10:13 AM7/24/08
to
Dear Brad,
I am getting closer to what I need.
I would like to export data from Diadem and put it into a csv format with the header file attached and the extra columns. I do not need to bring data into Diadem.
I have got the following VB script which opens a template file in Excel, but I cannot transfer the data from the Data Portal into the Excel sheet.
There must be a simple command to 'get data' or 'copy channels'
Attached is the data in TDM format and the VB script is below which I have obtained from a previous disscussion board.
Dim i, j, Excel, ExcelSheet, ExcelFilePath, ExcelWorkbook, ErrNumConst xlMaximized = &HFFFFEFD7Const StartDataRow = 22Const StartDataCol = 4 ' BExcelWorkbook = "Excel Template Camera.xls"ExcelFilePath = "D:\New_PC\Testing\DataonScreen\" & ExcelWorkbook' Start Excel via OLE, a new Excel instance always starts.On Error Resume NextSet Excel = CreateObject("Excel.Application")ErrNum = Err.NumberOn Error Goto 0IF ErrNum <> 0 THEN Call AutoQuit("Error opening Excel Template File")Excel.Visible = True ' Show Excel if Excel was hidden up to nowExcel.WindowState = xlMaximized ' Maximize Excel window' Call WndShow("SHELL", "MINIMIZE") ' Minimize DIAdemExcel.Workbooks.Open(ExcelFilePath) ' Open Excel FileSet ExcelSheet = Excel.Workbooks(ExcelWorkbook).Sheets("data")Excel.ScreenUpdating = False ' Disable screen refresh.ExcelSheet.Cells(4, 22).Select ' Select first cell in the worksheet
'This is where I would like to bring the channel data in.
Excel.ScreenUpdating = True ' Enable screen refreshExcelSheet.Parent.Saved = FALSE ' force "save changes?" questionIF 1 = 0 THEN Excel.QuitSet ExcelSheet = Nothing ' Release the object variable memorySet Excel = Nothing      ' Release the object variable memory
Thanks
Stagsden


New WinZip File.zip:
http://forums.ni.com/attachments/ni/60/9087/1/New WinZip File.zip

Brad Turpin

unread,
Jul 24, 2008, 9:40:12 AM7/24/08
to
Hi stagsden,
Please post the TDX file that belongs to that TDM file-- the data values are stored in the TDX file you didn't post.  Also, it is important to send the values directly to Excel, or could we alternatively create a CSV file that could be loaded into Excel either manually or programmatically?  For larger data sets sending values through ActiveX can be slow, and the ActiveX connection has its own foibles.

Stagsden

unread,
Jul 24, 2008, 11:10:12 AM7/24/08
to
Tdx file attached


Camera tdx.zip:
http://forums.ni.com/attachments/ni/60/9089/1/Camera tdx.zip

Brad Turpin

unread,
Jul 25, 2008, 10:10:15 AM7/25/08
to
Thanks stagsden,
Things are coming into focus now-- I can clearly see the data you have to start with in DIAdem and the exported csv file format you want to end up with.  There are 3 elements in the desired CSV header you sent that I can read from the TDM file:
#Date,,02/07/2008#Time,,16:37:42#NumberOfDatas,,10000,,,,
But the remainder of the desired CSV header items do not seem to be anywhere in the TDM file.  Do you want to use the same hard-coded values that you sent me for all exported CSV files?  Will the TDM file have this information in the future?  If so, where will the information reside-- File properties, Group properties, Channel properties, or in some external ASCII file?
#PHOTRON MCDL DATA,,#SheetType,,A#CameraType,,FASTCAM-APX RS 250K#CameraID,,5#FrameRate(fps),,1000#SaveStep,,1#ShutterSpeed(sec),,1/1000000#ImageWidth,,512#ImageHeight,,592#TriggerMode,,End#NumberOfFrames,,500#FrameRange,,0 to 500#UseZeroFrame,,0#SamplingRate(sps),,20000#Sloap,,,1,1,1,1#Intercept,,,0,0,0,0
Also, the CSV file you sent seems to assume there are 19 data points per frame-- will this always be the case, or will this information also be in the TDM file?  This information is required to correctly create all 3 extra columns in the CSV file you sent me.

Stagsden

unread,
Jul 28, 2008, 4:40:12 AM7/28/08
to
Hello Brad,
Yes, the 19 lines of property data will not be in the original TDM file, they will be 'hard coded' into the newly created csv file, with the exception of date, time and number of points that can be added to the top section.
It would also be useful to put the name of the data into the name of the newly created csv file. The 19 lines of property data can reside in an external ASCII file.
The first 19 points are in one frame, then subsequently there are 20 points in each frame. This will always be the case.
There may be upto 10,000 points.
Regards
Stagsden

Brad Turpin

unread,
Jul 28, 2008, 11:40:12 AM7/28/08
to
Hi stagsden,
Here's what I think you want.  You didn't specify where the file name was supposed to go and whether you meant the name of the TDM file or the name of the TDM group, so I included both of them in the header.  As I suggested in my earlier posts, the VBScript creates a *.csv file which loads up in Excel by just double-clicking on the file.

Brad TurpinDIAdem Product Support EngineerNational Instruments


Export to CSV File.zip:
http://forums.ni.com/attachments/ni/60/9101/1/Export to CSV File.zip

Stagsden

unread,
Jul 28, 2008, 12:10:09 PM7/28/08
to
Brad,
Thanks, does the job perfectly. 
I would go home for the day if I was you, you have done a days work already.
Stagsden
0 new messages