[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

A script to try opening a file until correct App Version is found

Posted on 2007-07-19
5
Medium Priority
?
215 Views
Last Modified: 2010-04-16
Good morning scripting experts

I've had an idea to an issue that fairly frequently arrises.  We use MYOB software and receive ledgers from a range of software versions.  We do have 3rd party software that helps us ascertain which version of the MYOB software we need to use to open the software.  Trouble is the 3rd party software doesn't always corrently identify the version of MYOB required to open the ledger file.  When this happens we then have to open all versions of MYOB sequentially and try the ledger and see if it is the correct version.  Quite tedious.  I have copied all MYOB application shortcuts to my desktop and can drop the ledger file onto each shortcut and see if it opens, if it does, happy days, if it doesn't then I try the next version of MYOB etc. Better but still tedious.

Soi thats the situation, how can you experts help me with scripting?

From a high level view it would be great if the script could

ask for the path to the ledger file
Try and open the 1st version of myob using the supplied ledger file
Ask the user if the ledger opened via a msgbox
If the ledger did open ok then end script otherwise try the next version of MYOB

Thanks for input on this one

Rob
0
Comment
Question by:robjeeves
  • 3
  • 2
5 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 19527698
Hi Rob,
Before we go down that track, is there ANYTHING in the File Properties of the Ledger file that tells you anything about the MYOB version?  That's a long shot, but worth asking......

Otherwise, we'll look at doing what you have mentioned....

Rob.
0
 
LVL 9

Author Comment

by:robjeeves
ID: 19527786
Afraid not. Well not overly.  The MYOB apps have different extetnions
.dat = Accounts Plus
.prm = Premiere
.myo = Newest ledgers that include Accounts Plus and Premeire

The file properties are empty for these files though, the 3rd party software once it sucessfully ascertains the version of MYOB writes the MYOB into file properties so subsequent opening are quicker.

Talking of Long shots - Do you happen to be Rob from Dartford? I used to work with another Rob when I worked at Apple Computers a few years ago with the same name :-) Could it be you? :-)
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 19527877
No, if the Dartford you are referring to is in England, that's quite a distance from Victoria, Australia. Sorry.

OK, so try this VBS file and see how you go.  Note that you will need to change the arrMYOBs values to reflect your MYOB versions:
'==================
Dim arrMYOBs
arrMYOBs = Array( _
      "C:\Program Files\MYOB Accounting Plus\MYOB.exe", _
      "C:\Program Files\MYOB Accounting\MYOB.exe", _
      "C:\Program Files\MYOB First\MYOB.exe" _
      )

Dim objDialog, intResult, objFSO, objFile, strOption, objOption
Const intForReading = 1

Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "All Files (*.*)|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "."
intResult = objDialog.ShowOpen

If intResult = 0 Then
    MsgBox "No file was selected. The script will not continue."
    WScript.Quit
End If

strFileName = objDialog.FileName

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
For intCount = LBound(arrMYOBs) To UBound(arrMYOBs)
      strCommand = """" & arrMYOBs(intCount) & """ """ & strFileName & """"
      'MsgBox strCommand
      objShell.run strCommand, 1, False
      strResponse = MsgBox("Did the ledger file open correctly?", vbYesNo, "Did the file open correctly?")
      If strResponse = vbYes Then Exit For
Next

MsgBox "Done"
'=================

Regards,

Rob.
0
 
LVL 9

Author Comment

by:robjeeves
ID: 19528021
re England: Yes it was England, oh well.

Anyway, that is awesome mate.  Have tested it and it works sweet. Thanks so much
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 19528042
No problem.  We could probably go a little further and narrow down the programs it tries to open with, according to the file extension, if you're interested?  But that would only prevent two or three attempts.....and you can always change the order of the arrMYOBs lines, to emulate a "preference".

Regards,

Rob.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question