What is the proper way to use this method? Not having any luck.
Also tried using oDoc.Sheets.Item(2) for Target Sheet.
Public Sub MoveViews() Dim oApp As Application Set oApp = ThisApplication Dim oDoc As DrawingDocument Set oDoc = oApp.ActiveDocument Dim oSheet As Sheet Set oSheet = oDoc.ActiveSheet ' Check to make sure a view was selected. If Not TypeOf oDoc.SelectSet.Item(1) Is DrawingView Then MsgBox "A drawing view must be selected." Exit Sub End If Dim oDrawingView As DrawingView Set oDrawingView = oDoc.SelectSet.Item(1) ' Test to see if we have the view oDrawingView.ShowLabel = True ' Move view to target sheet oDrawingView.MoveTo ("Sheet:2") End Sub
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
Can you double check that the active sheet is Sheet:2 or not? You could not move a drawing view to the same sheet it is located in.
Seems there is a code error, please use below updated code:
Public Sub MoveViews() Dim oApp As Application Set oApp = ThisApplication Dim oDoc As DrawingDocument Set oDoc = oApp.ActiveDocument Dim oSheet As Sheet Set oSheet = oDoc.ActiveSheet ' Check to make sure a view was selected. If Not TypeOf oDoc.SelectSet.Item(1) Is DrawingView Then MsgBox "A drawing view must be selected." Exit Sub End If Dim oDrawingView As DrawingView Set oDrawingView = oDoc.SelectSet.Item(1) ' Test to see if we have the view oDrawingView.ShowLabel = True ' Move view to target sheet oDrawingView.MoveTo oDoc.Sheets("Sheet:2") End Sub