Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to set focus on desired activeDocument?

Status
Not open for further replies.

kivancsi

Mechanical
Jun 19, 2013
4
Hi everyone!

How can I change the activeDocument from Part to Assembly and back in an API written in Visual Basic 6?

Indeed my problem is I open a Part modify it and close it with
objDocP.Close

then open the assembly on the way

'Connect to a running instance of Solid Edge.
Set objApp = GetObject(, "SolidEdge.Application")
If Err Then
'Clear the error.
Err.Clear
'Start Solid Edge.
Set objApp = CreateObject("SolidEdge.Application")
End If
'Turn off error handling.
On Error GoTo 0
'Make the application window visible.
objApp.Visible = True
'Access the Documents collection.
Set objDocs = objApp.Documents
'Find out if any documents are open.
If objDocs.Count = 0 Then
'Add an Assembly document.
Set objDoc = objDocs.Add("SolidEdge.AssemblyDocument")
Else
'Access the currently open document.
Set objDoc = objApp.ActiveDocument
End If

and get an Error for Set objDoc

but when I put infront of Set objDoc an If

'Access the currently open document.
If objApp.ActiveDocumentType <>3 Then MsgBox objApp.Name
Set objDoc = objApp.ActiveDocument

it works, but I have to push OK button on messagebox


so the question is: how can I ater closing the PartDocument set the focus on opened AssemblyDocument?
 
Replies continue below

Recommended for you

I have found the solution, maybe it will be useful for someone

Instead of Set objDoc = objApp.ActiveDocument the part between Else adn End If looks like this

Else
Set objDoc = objDocs.Item(1)
objDoc.Activate
End If


'remark> Item(1) since after closing the part file only the assembly file is opened
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor