Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Eng-Tips
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

how to set focus on desired activeDocument?

how to set focus on desired activeDocument?

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

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.
'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")
'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?

RE: how to set focus on desired activeDocument?

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

Set objDoc = objDocs.Item(1)
End If

'remark> Item(1) since after closing the part file only the assembly file is opened

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!

Share a File


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close