Macro Crashing When Opening an Assembly Update??

Update 4/8/08



The Question I have is how do I get the solidwoks window to havefocus when using the "opendoc6" call??

I am a visual basic newbie. I know enough to be dangerous.

I have included the Code that opens the assembly to read the custominfo below. I highlighted the call to open the assembly.

Why does the problem only affect assemblies. This does not happenwhen opening parts or drawings???

Any Help would be appreciated!!!

Thanks Rick

I found out that it is the application focus when trying to open anassembly. I you do an Alt Tab and bring Solidworks into theforeground it will finish processing the assembly.

4/9/08
Some more Info. The macro calls to open the current asslembly inthe list and solidworks starts to open the assembly file and youget the progress window which says Loading. At the point where theloading progress screen comes up is where it freezes. I then do analt tab and switch to the solidworks application window and it willfinish processing?? Everytime the macro says to open the currentassembly file in the list using Opendoc6 function it will freeze onthe loading screen, until switching to the solidworks applicationscreen using alt tab keys????


Private Sub CmdProcess_Click()
Dim longErr As Long, longWarn As Long
ProcessStart
ListBoxOutput.ColumnCount = 6
ListBoxOutput.ColumnWidths = "50pt; 30pt; 30pt; 20pt; 20pt; 150pt"' max 300
For Counter = 0 To ListBoxOutput.ListCount - 1
Filename = ListBoxOutput.List(Counter, 0)
SimpleStatus "Processing: " + Filename
FileType = UCase(Right\$(Filename, 3))
If FileType = "PRT" Or FileType = "ASM" Or FileType = "DRW" Then
FileOpen = swApp.GetCurrentWorkingDirectory + Filename
If FileType = "PRT" Then
Set ModelDoc2 = swApp.OpenDoc6(FileOpen, 1, &H1, " ", longErr,longWarn)
ElseIf FileType = "ASM" Then
Set ModelDoc2 =swApp.OpenDoc6(FileOpen, 2, &H1, " ", longErr, longWarn)
ElseIf FileType = "DRW" Then
Set ModelDoc2 = swApp.OpenDoc6(FileOpen, 3, &H1, " ", longErr,longWarn)
End If
If Not ModelDoc2 Is Nothing Then
Title = ModelDoc2.GetTitle
Temp = UCase(Mid(Title, (Len(Title) - 6), 7))
NewParseString Title, ".", 1, 0
GetInfoData FileType
Else
ShowInfoUpdate Counter, Title, FileType, "?", "?", "?", "NotLoaded?"
End If
End If
Set ModelDoc2 = Nothing
swApp.CloseDoc Filename
Next Counter
SimpleStatus "Done."
CmdProcess.Enabled = True
CommandExport.Enabled = True
ProcessEnd
If CheckBoxExport = True Then CommandExport_Click
If CheckBoxClose = True Then CommandClose_Click
End Sub



Edited: 04/08/2008 at 06:03 PM by Rick Tucker
SolidworksApi macros