using openDoc6 browse for missing file.

Programming and macros
colt
Posts: 56
Joined: Tue Mar 30, 2021 5:43 pm
Answers: 0
x 14
x 22

using openDoc6 browse for missing file.

Unread post by colt »

How can I trigger the browse for file popup if using openDoc6?
User avatar
SPerman
Posts: 2080
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 14
x 2256
x 1902
Contact:

Re: using openDoc6 browse for missing file.

Unread post 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
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
colt
Posts: 56
Joined: Tue Mar 30, 2021 5:43 pm
Answers: 0
x 14
x 22

Re: using openDoc6 browse for missing file.

Unread post 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.
User avatar
Stefan Sterk
Posts: 37
Joined: Tue Aug 10, 2021 2:40 am
Answers: 3
x 51
x 77

Re: using openDoc6 browse for missing file.

Unread post 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)
colt
Posts: 56
Joined: Tue Mar 30, 2021 5:43 pm
Answers: 0
x 14
x 22

Re: using openDoc6 browse for missing file.

Unread post 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.
Post Reply