style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<stuartmp> wrote in messageHi
href="news:6050597@discussion.autodesk.com">news:6050597@discussion.autodesk.com...
All I was just wondering if it is possible to get the current sheet number
through VBA? Thanks
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<stuartmp> wrote in messageHi
href="news:6050597@discussion.autodesk.com">news:6050597@discussion.autodesk.com...
All I was just wondering if it is possible to get the current sheet number
through VBA? Thanks
yes...
Public Sub x()
'The sheet number is appended to the sheet name in _
the browser. You can get this name using the Name _
property of the Sheet object and then extract the number from the name. *Brian Ekins
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
Dim NoOfSheets As Integer
Dim CurrentSheet As Integer
NoOfSheets = oDoc.Sheets.Count
Dim strSheetName As String
strSheetName = oDoc.ActiveSheet.Name
If InStr(strSheetName, ":") Then
' Extract the sheet number from the name.
GetSheetNumber = CInt(Right$(strSheetName, Len(strSheetName) - InStrRev(strSheetName, ":")))
Else
'This sheet is not numbered so returnzero.
GetSheetNumber = 0
End If
CurrentSheet = GetSheetNumber
Debug.Print CurrentSheet
Debug.Print NoOfSheets
End Sub
Isn't the sheet number the same as the document.sheets index value? If so;
dim sheetNo as integer = 0
For index as Integer = 1 to document.sheets.count
if documents.sheets(index).name = activesheet.name then
'sheet number found it is index.
sheetNo = index
exit for
end if
next
i am not quiet sure about that...but the solution posted by Brian Ekins seems to work fine...