[Use your browser's BACK button to return to the PRIME FAQ Page or click here if you came directly to this page.]
This was taken from the PRIME for Excel and PRIME for Word APIs. These APIs are available in our Word and Excel shareware packages which can be downloaded from our Products page.
In Word it’s often useful to know if the current child window represents a document, a template, or a macro (a Word child window containing a macro is sometimes called the "macro editing pane"). Unfortunately, there’s no single built-in function to do this for you. The classic SelInfo(27) — which returns true if you’re in a macro editing pane — gets you a third of the way there, but we wanted a single function to return a value indicating exactly which of these three possible "types" the current window belongs to. Jonathan Sachs wrote fWindowType to do just that.
Shown below is a WordBasic example that calls the function, presumed to be stored in the procedure library macro GeneralLib, followed by the function’s WordBasic source code.
' WordBasic calling example
Sub MAIN
rc = PrimeLib.fWindowType
Select Case rc
Case 0
MsgBox "There's a document in the current window."
Case 1
MsgBox "There's a template in the current window."
Case 2
MsgBox "There's a macro in the current window."
End Select
End Sub
' WordBasic...
' --------------------------------------------------------------------
' Purpose: Return the type of the active window: document, template,
' or macro.
'
' Inputs: None
'
' Returns: 0 for document, 1 for template, 2 for macro
'
' Updated: (PCG: JS)
' --------------------------------------------------------------------
' Copyright © 1994-96 PRIME Consulting Group, Inc.
' --------------------------------------------------------------------
Function fWindowType
If SelInfo(27) <> 0 Then
fWindowType = 2 ' It's a macro.
Else
Dim FTdlg As FileTemplates
GetCurValues FTdlg
If FTdlg.Template = "" Then
fWindowType = 1 ' It's a template.
Else
fWindowType = 0 ' It's a document.
EndIf
EndIf
End Function
|