Sign in to follow this  
Followers 0
ParaffinPower

Beginner questions

7 posts in this topic

Hi CX-S is very new to me, and I have a few questions. I'm logging data to Excel, which is working well. I'd like to automatically create a new XLS from a button push(from an Excel Template) and continue logging. I'm sure it's just a bit of VB script, but I'm learning. Will I be able to name the file? Will I have to temporarily stop logging whilst the new sheet is created? Thanks, Pp

Share this post


Link to post
Share on other sites
Hi PP, At first it seems a bit obvious you will have to stop logging, but actually there are quite some questions about what you're doing... a) If you're using the CX-Supervisor Data Logging feature, to log to a DLV file but then export to an XLS file then you can name the file you are exporting to. b) If you're using the CX-Supervisor Database function to log to Excel directly (or via data logging feature!) then you can use a DBExecute command to change the "Source" of the Recordset, to log to a new file. c) If you're using VBScript with ActiveX object "Excel.Application" then I think this offers all the commands needed. d) And are you actually creating a new XLS File, or just a sheet within the current file? e) If you're using DDE: good luck - you're on you're own Which of these are you doing? Without all the knowledge, my first thought is actually you probably want to seperate the data logging from the data viewing. Therefore you would use a hidden database (or relectantly, a XLS) to log ALL data and use other spreadsheets to 'query' the data as required. About the Button... Are you talking about a CX-Supervisor button, of a XLS button on the spreadsheet? I assume this is CX-Supervisor as the action would have to control the CX-Supervisor logging. Regards, Bertie

Share this post


Link to post
Share on other sites
Hello Bertie, And thank you for the reply. Looks like the DBExecute command requires my attention. I'm logging directly to Excel. My next question might be that I'd like the filename to include today's date (not 28th July ). When I mentioned the 'button', this was just a 'host' for the script to create a new XLS. This'll probably happen at midnight automatically. If I know the syntax, then whether it be behind a button or on an event isn't important? (I think) Thanks again, B Pp

Share this post


Link to post
Share on other sites
Adding the date should be no problem... you can just generate the filename at runtime using string concatination something like DBExecute .... "C:\\Path\\File" + $Date, ... $Date (for CX-Supervisor Script language) or s_Date (for VBScript) are predefined system strings that always hold the date. Therefore just appending this string to your filename (or maybe using $Day, $MonthName/$Month, $Year as you wish with some conversion code) should be a start. Sorry for no executable code snipit but it's Friday afternoon Incidently, an Event script using $Date would be an ideal way to trigger automatically when the Date changes (i.e. midnight!). As long as you mean scrip within CX-Supervisor as opposed to XLS button, then there's no difference in the language or execution between events or buttons. If this doesn't get you sorted I'll post some code next week Bertie

Share this post


Link to post
Share on other sites
Hi Bert I've come up with a couple of scripts which may be able to help me. I can create a new XLS, and format it correctly (column headings, naming a range of data...etc). From this, I'll be able to Log to 'Book1'. I just need to find the name which the new Excel file has taken (in case it's not Book1) and try and point the Database connection toward this. If you'd like to see my script attempt, let me know. Pp

Share this post


Link to post
Share on other sites
Hello Pp, Just a quick word of warning over using system dates, times etc... Watch how this is set in the PC, as quite often, the default seperators will contain illegal filename characters (e.g. '-' ). I tend to use a colon as the seperator.

Share this post


Link to post
Share on other sites
Hi Pp, Yes I'd love to see the scripts - also to help understand if they're XLS macros or CX-Supervisor/VBScript scripts. Anyway, I would think that the Workbook name is under your control? If you're creating the file (e.g. by copying) I assume you choose the filename already. If you're creating a new file, I assume by Saving the workbook you specify the filename? Can you execute a "Save as" command to name it? Regards, Barry.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0