terrypin Posted September 21, 2017 Author Report Share Posted September 21, 2017 Thanks, VBS looks a fascinating alternative approach. It will mean using any suitable scripts I can find in "copy/paste and don't try to understand the detail" mode, painful for me. But the potential advantages outweigh that. Wish I'd thought of exploring it before I wrote my 114 liner yesterday! Did you mean to include a sample script in your post? Long time since I played with VBS and it's not immediately obvious to me how you got that date into an ME or MEP MsgBox? Quote Link to comment Share on other sites More sharing options...
rberq Posted September 21, 2017 Report Share Posted September 21, 2017 Yes, I did include a sample script in the post. MsgBox(DateAdd("s",30,"31-Jan-10 08:50:00")) is a complete script. That one line is the entire text (script) file that my macro built. The display is NOT a Macro Express message box, it is a VBScript message box. A macro was used only to write that one line to a text file, to save the text file with the .vbs filetype, and to launch Windows WSCRIPT.EXE which runs the script file. You can simulate this manually by building and saving the one-line script file with Notepad, then typing "WSCRIPT.EXE filename.vbs" at a command prompt or the Windows "Start" command. For your purposes, a message box output is useless, so do some Googling and copy/paste file-building logic so that the (1) macro builds a bigger script, (2) the macro launches WSCRIPT to run the script, (3) the script writes the computed date result to a (second) text file, then (4) the macro retrieves the text file containing the result. It seems convoluted, but after you get it working you may come up with a simpler method. In my mind, the biggest advantage of using VBScript is that Microsoft has already written hundreds or thousands of lines of code to make DateAdd do accurate calculations that span day-end, month-end, year-end, etc. P.S. Getting familiar with Visual Basic and similar object-oriented languages IS painful for somebody used to step-by-step logic. I have suffered through it and have very far to go, probably will never get there at my advanced age. But it is worth it, so get going. Google is your friend. Quote Link to comment Share on other sites More sharing options...
terrypin Posted September 21, 2017 Author Report Share Posted September 21, 2017 Thanks for the helpful follow-up. Now reproduced your output (happily in UK dd/mm format, presumably via Win 10 international settings). And 'Learn VB Scripting' added to my long To Do list! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.