Re: HTA / IE7 question... by Blue
Blue
Mon May 14 10:25:35 CDT 2007
On May 11, 9:34 pm, Blue Streak <rdlebre...@hotmail.com> wrote:
> Michael Harris (MVP) wrote:
>
> > Where exactly does App.Path come from?
>
> > Michael Harris
> > Microsoft.MVP.Scripting
>
> Forgot about that!!
>
> Here it is:
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DVBSLib.vbs=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
> '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=AD=3D=3D=3D=3D=3D
> 'Library Name: VBSlib
> 'Description: Library file containing useful VBScript functions and
> constants
> '
> 'Requirements: WSH 5.5 or higher
> ' Internet Explorer 5.5 or higher
> '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=AD=3D=3D=3D=3D=3D
>
> '-----Useful Constants-----
> 'Pop-up dialog
> Const vbNoResponse =3D -1
>
> 'FileSystemObject Text Files
> Const vbOpenAsASCII =3D 0
> Const vbOpenAsUnicode =3D -1
> Const vbOverwriteIfExist =3D -1
> Const vbFailIfExist =3D 0
> Const vbOpenAsDefault =3D -2
> Const vbCreateIfNotExist =3D -1
> Const vbFailIfNotExist =3D 0
> Const vbForReading =3D 1
> Const vbForWriting =3D 2
> Const vbForAppending =3D 8
>
> 'File Attributes
> Const vbFileAttrNormal =3D 0
> Const vbFileAttrReadOnly =3D 1
> Const vbFileAttrHidden =3D 2
> Const vbFileAttrSystem =3D 4
> Const vbFileAttrVolume =3D 8
> Const vbFileAttrDirectory =3D 16
> Const vbFileAttrArchive =3D 32
> Const vbFileAttrAlias =3D 64
> Const vbFileAttrCompressed =3D 128
>
> '-----Useful Functions / Subroutines-----
> Function IsAlpha(szInput)
> 'Test input for alphabetic characters only
> Dim nPos, bValid, nOne
> nPos =3D 1
> bValid =3D False
>
> While nPos <=3D Len(szInput) AND bValid
> nOne =3D Asc(UCase(Mid(szInput,nPos,1)))
>
> If nOne >=3D Asc("A") AND nOne <=3D Asc("Z") Then
> bValid =3D True
> End If
>
> nPos =3D nPos + 1
> Wend
>
> IsAlpha =3D bValid
> End Function
>
> Function IsAlphaNum(szInput)
> 'Test input for alphanumeric characters only
> Dim nPos, bValid, nOne
> nPos =3D 1
> bValid =3D False
>
> While nPos <=3D Len(szInput) AND (bValid =3D False)
> nOne =3D Asc(UCase(Mid(szInput,nPos,1)))
>
> If (nOne >=3D Asc("A") AND nOne <=3D Asc("Z")) OR (nOne =
>=3D Asc("0") AND
> nOne <=3D Asc("9")) Then
> bValid =3D True
> End If
>
> nPos =3D nPos + 1
> Wend
>
> IsAlphaNum =3D bValid
> End Function
>
> Function IsNothing(objVar)
> 'VB6 implementation of IsNothing in VBScript
> If TypeName(objVar) =3D "Nothing"Then
> IsNothing =3D True
> Else
> IsNothing =3D False
> End If
> End Function
>
> Function IIf(Expression, TruePart, FalsePart)
> 'VB6 implementation of Immediate If in VBScript
>
> If Expression =3D True Then
> If IsObject(TruePart) Then
> Set IIf =3D TruePart
> Else
> IIf =3D TruePart
> End If
>
> Else
> If IsObject(FalsePart) Then
> Set IIf =3D FalsePart
> Else
> IIf =3D FalsePart
> End If
>
> End If
>
> End Function
>
> Class clsApplication
> Property Get Path()
> If IsObject(WScript) Then
> 'Windows Scripting Host
> Path =3D Left(WScript.ScriptFullName,
> InStr(WScript.ScriptFullName, WScript.ScriptName) - 2)
> ElseIf IsObject(window) Then
> 'Internet Explorer HTML Application (HTA)
> szTmp =3D Replace( Replace(Unescape(window.location),
> "file:///", "") ,"/", "\")
> Path =3D Left(szTmp, InstrRev( szTmp , "\") - 1)
> End If
> End Property
> End Class
> '=3D=3D=3D=3D=3DFor App object=3D=3D=3D=3D=3D
> Dim App : Set App =3D New clsApplication 'use as App.Path
>
> Function vbIsArray(arr)
> 'For JS function call
> vbIsArray =3D IsArray(arr)
> End Function
>
> Function vbUBound(arr)
> 'For JS function call
> vbUBound =3D UBound(arr)
> End Function
>
> '-----Function used to include this library file-----
> 'Requirement: VBScript 5.6 (WSH 2.0) or higher
> 'Description: Returns True if library was loaded successfully
> '----------------------------------------------------
> 'Function Include(sFileSpec)
> ' On Error Resume Next
> '
> ' With CreateObject("Scripting.FileSystemObject")
> ' ExecuteGlobal .OpenTextFile(sFileSpec, 1).ReadAll
> ' Include =3D (Err.Number =3D 0)
> ' End With
> 'End Function
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
To answer my own question: I was able to open the PDF file by sticking
"explorer" in front of the path of the document. It helps to have
double-quotes around the path.