|
发表于 2022-12-13 13:31:53
|
显示全部楼层
- U/ [! Y: g! {; V
多加一行代碼就可以了…
5 K/ C1 |5 \: i- ~. A% e: S. A o1 i6 M# e- d K
- Option Explicit
4 {" V) r, j$ j' g' _8 i
: s6 a f# J; z! N- p- Dim swApp As SldWorks.SldWorks
* O: j; L8 _# N- t6 y - Dim swFilter As String, fileName As String, fileConfig As String, fileDispName As String
$ A& e- n; _4 R; L/ d: R& h! D% k - Dim fileOptions As Long
3 z4 \& q9 m/ `( `9 c9 P
) J2 l8 k; q: L9 M; S- Sub main()
: _+ H" W2 S1 X Y - Set swApp = Application.SldWorks
# I- V' [ s& d: C' a1 t$ M - swFilter = "All(*.*)|*.*"
& c, D4 C, w a9 G- w3 I6 v
. ^% l3 k w, @1 `& T- ' Browse and get the Selected file name
' K8 r0 X) t% j$ ^ - fileName = swApp.GetOpenFileName("Browse Document", "", swFilter, fileOptions, fileConfig, fileDispName)
/ V, f9 y3 ?# w+ h/ f7 s - ' Get the path of the selected file- V/ Y. V8 o8 C( A. x' `
- fileName = Left(fileName, InStrRev(fileName, ""))
8 e5 X7 ?3 c7 l - Debug.Print fileName
! c4 X5 ?: u7 Z# m, d S" s - End Sub
2 A) R) l+ G% p0 T3 Q
复制代码 6 p. R$ f) Z- q u n: z1 |
9 d0 E* L, M# W7 T
|
|