AnsweredAssumed Answered

How to Set swModel to certain file without opening to extract ArtNr

Question asked by Robert Voogt on Jul 26, 2018
Latest reply on Aug 2, 2018 by Danniel Sims

Hi all,

 

                            Set swModel = swApp.OpenDoc6(DrawFile, swDocDRAWING, 2, "", fileerror, filewarning)
                            fileArtNr = swModel.CustomInfo("ArtNr")
                            If InStr(UCase(fileArtNr), "SA") Or InStr(UCase(fileArtNr), "SP") Or InStr(UCase(fileArtNr), "IE") Or InStr(UCase(fileArtNr), "FM") Then
                            Else
                            GoTo LabelNext
                            End If

 

I use this in my code to check if the file I'm going to open has SA, SP, IE or FM in the name (fileArtNr). Only if it is, then the code continues, else it will go to labelnext.

DrawFile is the path to the file.

But the macro still opens all files (I have the code loop through a folder). (Also those that don't have SA (or 1 of the others) in the name.)

 

I also tried:

Set swModel = DrawFile

and

fileArtNr = DrawFile.CustomInfo("ArtNr")

But both gave errors.

 

The code does work when it is placed in the macro that is run after opening the file, then it will close the file if it's not an SA for example, but simply opening the wrong file and closing it again takes time.

 

So in short, I need the information that I correctly get when solidworks has opened the file (fileArtNr), but I need it before opening the file. This will speed up the proces a lot.

Outcomes