Find IDEA version number from script

6 posts / 0 new
Last post
Ken Brown
Offline
Joined: 07/15/2014 - 02:23
Find IDEA version number from script

Just wondering if it's possible to find the IDEA version number from within a script.  Our organisation is running IDEA 8.5 generally but have IDEA 9.1 on some computers and will be migrating there sometime in the future for the rest.  I have a script where I would like to know which version it is running under so that it can handle the differences between 8.5 and 9.1 in importing files with [ and ] brackets in the source file names (8.5 allows the brackets but 9.1 can't handle it).  This is a common occurrence for us as we see a lot of MYOB systems and some of the common MYOB reports default to brackets in the file names.
In Excel VBA I can use Application.Version to get the Excel version number.  I tried this with IDEAscript. In 8.5 it returned nothing. In 9.1 it crashed.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Ken and welcome to the site.

IDEA doesn't have a function to get the version number but I use the following routine to obtain the version number.  The function tests to see if a function available only in V9 works, if it gives an error it knows that you are using V8 else it returns V9.  Hopefully this will help you out.

'****************************************************************************************************
'	Name:		verIDEA
'	Description:	Routine to return the version of IDEA 8 or 9
'	Last Update:	
'	Accepts:		nothing
'	returns:		"8" or "9"
'****************************************************************************************************

Function verIDEA() As String

	Dim openDlg As Object
	Err.number = 0 'reset error to 0
	
	On Error Resume Next
	Set openDlg = Client.CommonDialogs
	If Err.number = 0 Then
		verIDEA = "9"
	Else
		verIDEA = "8"
	End If
	
	Err.number = 0 'reset error to 0
	Set openDlg = Nothing
End Function

 

Ken Brown
Offline
Joined: 07/15/2014 - 02:23

Thanks Brian.  That's great for the the situation I had above.  Unfortunately I now have another issue where I would like to be able to distinguish between IDEA 9.1 and 9.2 and I guess your technique won't work for that.  In Australia our financial year ends on 30 June and the second parameter for @FinYear should therefore be "0630".  This is how it was in 8.5 but in 9.1 you have to put in "0631" to make it work correctly.  I have been told that this has been fixed back to "0630" in 9.2 so if my script knew it was running in just 9.1 it could allow for problem.  At least your technique will help with our transition from 8.5 to 9.1.  I guess I need to hope there is a new function to test for in the next version we migrate to.  Thanks again.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Ken, you could try something out like this.  I don't have access at the moment to V9.1 so I am not sure what the result would be but as you can see you use the function and test for the different results to see if you are using 9.1 or 9.2.  The script probably needs some tweaking to make sure it captures the differences between the two.

Option Explicit
Dim bIsV91 As Boolean

Sub Main
	bIsV91 = checkIfV91()
	MsgBox bIsV91
	
End Sub

Function checkIfV91() As Boolean
	If iFinYear("20140630", "0630") = "2013-2014" Then
		checkIfV91 = False
	Else
		checkIfV91 = True
	End If
End Function

 

Ken Brown
Offline
Joined: 07/15/2014 - 02:23

Thanks Brian.  Great solution.  Worked well in showing the difference between 8.5 and 9.1, so should continue to work when the problem is fixed in the next version we move to.  Thanks again.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Ken, glad it worked.