API, changing active sheet on multiple sheet drawing
API, changing active sheet on multiple sheet drawing
(OP)
Hey all,
I am trying to change the focus from one sheet to another in a SolidWorks drawing using VBA.
Below is a clip from my macro. The swDraw.GetCurrentSheet line works fine so I think I have the correct libraries loaded but the swDraw.SheetNext (or SheetPrevious) does not work. I get "Compile Error: Expected Function or Variable"
and the .SheetNext is highlighted. I checked spelling and all. I dim'd the swNextSheet as Sldworks.Sheet as I did swsheet.
Set swsheet = swDraw.GetCurrentSheet
Set swNextSheet = swDraw.SheetNext
I'm still pretty new at VBA especially in SolidWorks.
Any help's appreciated
Thanks
I am trying to change the focus from one sheet to another in a SolidWorks drawing using VBA.
Below is a clip from my macro. The swDraw.GetCurrentSheet line works fine so I think I have the correct libraries loaded but the swDraw.SheetNext (or SheetPrevious) does not work. I get "Compile Error: Expected Function or Variable"
and the .SheetNext is highlighted. I checked spelling and all. I dim'd the swNextSheet as Sldworks.Sheet as I did swsheet.
Set swsheet = swDraw.GetCurrentSheet
Set swNextSheet = swDraw.SheetNext
I'm still pretty new at VBA especially in SolidWorks.
Any help's appreciated
Thanks






RE: API, changing active sheet on multiple sheet drawing
RE: API, changing active sheet on multiple sheet drawing
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swDwg As DrawingDoc
Dim swSht As Sheet
Dim sThisSheet As String
Dim sSheetNames As Variant
Dim iSheets As Integer
Dim j As Integer
Set swApp = GetObject(, "SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swDwg = swModel
Set swSht = swDwg.GetCurrentSheet
sThisSheet = swSht.GetName
iSheets = swDwg.GetSheetCount
sSheetNames = swDwg.GetSheetNames
For j = LBound(sSheetNames) To UBound(sSheetNames)
If sSheetNames(j) <> sThisSheet Then
swDwg.ActivateSheet sSheetNames(j)
Exit For
End If
Next j
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.