How to specify date range in Analysisdoc(s)

Hi Seniors,

The old analysis object is able to set the RangeFromDate and RangeToDate in exploration but it said that this object is obsolete. But the new automatic analysis is using AnalysisDoc and AnalysisDocs, however it seems that both of them does not contain the properties for specifying the date range to scan or explore.

So, are there any way to explicitly specify the date range for New Analysis window. I want it to be used in OLE automation.

Please guide.

Firstly: RangeFromDate/ToDate was abused (people were trying to set this from AFL formula being currently run which of course is not possible because the range is already set).

Secondly: Analysis project file (APX) contains ALL settings including the range, so you just need to set the dates, save analysis project and that's it.
Whenever you open APX file later (AnalysisDocs.Open) range will be set appropriately.

If you want to change the dates you can modify APX file as it is plain text (XML) format.

3 Likes

I call this vbscript in a batch file before calling AMI. It updates the ToDate in the project file.

Const ForReading = 1
Const ForWriting = 2
Dim objFSO, filepath, objFile, tmpStr, substrToFind, strToReplace, strUpdate
filepath = "Weekly BBO.apx"

wscript.echo "-- As the date changes find the string to replace --"
Set objFSO = CreateObject("Scripting.FileSystemObject")
substrToFind = "<ToDate>"
Set objFile = objFSO.OpenTextFile(filepath, ForReading)

Do until objFile.AtEndOfStream
   tmpStr = objFile.ReadLine
   if InStr(tmpStr, substrToFind) > 0 Then
		strToReplace = tmpStr
   end if
Loop

wscript.echo "set the date to today"
strUpdate = "<ToDate>" & date & "</ToDate>"	

wscript.echo "old " & strToReplace
wscript.echo "new " & strUpdate

wscript.echo "-- FindAndReplace --"
FindAndReplace filepath, strToReplace, strUpdate

function FindAndReplace(strFilename, strFind, strReplace)
    Set inputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(strFilename, 1)
    strInputFile = inputFile.ReadAll
    inputFile.Close
    Set inputFile = Nothing
    Set outputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(strFilename,2,true)
    outputFile.Write Replace(strInputFile, strFind, strReplace)
    outputFile.Close
    Set outputFile = Nothing
end function 

If you only change <ToDate> you can simply set it once to the far future date because it does not hurt to have it set beyond "today".

3 Likes