Page 1 of 1

using openDoc6 browse for missing file.

Posted: Tue Nov 15, 2022 5:12 pm
by colt
How can I trigger the browse for file popup if using openDoc6?

Re: using openDoc6 browse for missing file.

Posted: Tue Nov 15, 2022 5:45 pm
by SPerman
Typically the coder launches the file browser dialog, and feeds the values returned to the openDoc function.

This explains how it was done in VB6. I can't say if that is still up to date for the modern Solidworks VB API
http://www.vb-helper.com/howto_select_file.html

Re: using openDoc6 browse for missing file.

Posted: Tue Nov 15, 2022 6:31 pm
by colt
Whoops, I had this question open in another tab. Must have submitted by accident without giving all info.
Was trying to get this dialog when a referenced part is missing from the drawing
dialog.jpg
using this code

Code: Select all

Dim swApp As Object
Sub main()
    Set swApp = Application.SldWorks
    Dim err As Long
    Dim warn As Long
    dim fileP as string
    fileP = "mypath"
    Set res = swApp.OpenDoc6(fileP , swDocumentTypes_e.swDocDRAWING, swOpenDocOptions_e.swOpenDocOptions_Silent, "", err, warn)
    Debug.Print res.GetTitle
    Debug.Print err
    Debug.Print warn
End Sub
The dialog opens when opening from explorer or from solidworks file menu, but not api. My solution was to open the drawing manually and select Checked "don't show again" before selecting "Browse for file". Now openDoc6 will automatically present the open file window when something is missing.

Re: using openDoc6 browse for missing file.

Posted: Wed Nov 16, 2022 5:21 am
by Stefan Sterk
Hi @colt,

Replace swOpenDocOptions_e.swOpenDocOptions_Silent with Empty or -1.
swOpenDocOptions_e.swOpenDocOptions_Silent suppresses the warning dialogs like missing file.

Code: Select all

Set res = swApp.OpenDoc6(fileP , swDocumentTypes_e.swDocDRAWING, Empty, "", err, warn)
Instead of

Code: Select all

Set res = swApp.OpenDoc6(fileP , swDocumentTypes_e.swDocDRAWING, swOpenDocOptions_e.swOpenDocOptions_Silent, "", err, warn)

Re: using openDoc6 browse for missing file.

Posted: Wed Nov 16, 2022 9:47 am
by colt
Hmmm, when I use -1 it opens the document as [Viewing] [Read-only]. When Empty it loads as if I had the silent option. I made sure to allow all dismissed messages in options. I am on 2018, so maybe it works in newer versions.