home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 January
/
pcwk_01_1999.iso
/
Wtestowe
/
Vistdstd
/
Install
/
Data.Z
/
Doclist.BAS
< prev
next >
Wrap
BASIC Source File
|
1996-09-04
|
5KB
|
123 lines
Attribute VB_Name = "DOCLIST"
' -----------------------------------------------------------------------------
' Copyright (C) 1993-1996 Visio Corporation. All rights reserved.
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Visio has no warranty,
' obligations or liability for any Sample Application Files.
' -----------------------------------------------------------------------------
Option Base 0 '-- 0 Based Arrays
Option Explicit '-- All Variables Explicit
'--
'-- The array DocList is a global array which contains the most up to date
'-- list of Visio's valid, open documents. Use UpdateDocList to keep this
'-- list up to date.
'--
Dim DocList() As DOCUMENT '-- Loaded Document List
Dim bEmpty As Integer '-- Empty/Full Flag
Function DocCount() As Integer
'------------------------------------
'--- DocCount -----------------------
'--
'-- Returns the total number of documents in the document list.
'--
If bEmpty <> True Then
DocCount = UBound(DocList) + 1 '-- Return Valid Docs
Else
DocCount = 0 '-- No Documents
End If
End Function
Function GetCollIndex(iIndex As Integer) As Integer
'------------------------------------
'--- GetCollIndex -------------------
'--
'-- Returns an integer specifying the index of a document in it's respective
'-- collections. This separates the valid and invalid document indexes for
'-- any functions that need to deal directly with Visio doc. collections.
'--
'-- Parameters : iIndex An integer containing the 0 based index of a valid
'-- document.
'
'-- Returns : An Integer containing the 1 based colleciton index or -1 if
'-- iIndex is invalid.
Dim iCollIndex As Integer '-- Return Index
iCollIndex = -1 '-- Default to -1
If iIsWithin%(iIndex, 0, UBound(DocList)) And (bEmpty <> True) Then
iCollIndex = DocList(iIndex).iCollIndex
End If
GetCollIndex = iCollIndex
End Function
Function GetDocName(iIndex As Integer) As String
'------------------------------------
'--- GetDocName ---------------------
'--
'-- Retrieves a document name from the valid document list.
'--
'-- Parameters : iIndex An integer containing the 0 based index of a valid
'-- document.
'--
'-- Returns : A String containing the name associated with iIndex's document
'-- or "" if iIndex is invalid.
Dim strName As String '-- Return Index
strName = "" '-- Default To Empty Name
If iIsWithin%(iIndex, 0, UBound(DocList)) And (bEmpty <> True) Then
strName = DocList(iIndex).strDocName
End If
GetDocName = strName '-- Return Document Name
End Function
Sub UpdateValidDocList()
'------------------------------------
'--- UpdateDocList ------------------
'--
'-- Retrieves the valid documents from Visio and updates the document list.
'-- A valid document is defined by containing at least one page. Documents
'-- which fit this description are drawings.
'--
Dim docDoc As Visio.DOCUMENT
Dim iDocCount As Integer, I As Integer, iValid As Integer
AppConnect
bEmpty = True '-- Default To Empty
iValid = 0 '-- No Valid Documents
iDocCount = g_appVisio.Documents.Count '-- Get Document Count
If iDocCount > 0 Then '-- At Least One Doc...
ReDim DocList(iDocCount - 1) '-- Set Array Size
For I = 1 To iDocCount '-- Doc Loop...
Set docDoc = g_appVisio.Documents(I) '-- Get Next Document
If docDoc.Pages.Count > 0 Then '-- Valid Document...
DocList(iValid).strDocName = docDoc.Name '-- Store Name
DocList(iValid).iCollIndex = I '-- Store Index
iValid = iValid + 1 '-- Inc. Valid Count
End If
Next I
ReDim Preserve DocList(iValid - 1) '-- Clean Up Array
bEmpty = False '-- Not Empty
End If
End Sub