|
发表于 2022-12-13 13:31:53
|
显示全部楼层
来自: 中国台湾
- a" u7 \6 b6 N6 a2 R6 Q6 n
多加一行代碼就可以了…
( b* |) B2 l8 P" H! }* [+ g( ]& w3 J' _7 M% c
- Option Explicit
/ f- c$ t2 n+ Z2 b2 f# N& L- | - 5 \" Z0 z; } m0 x- Q- P* q# O
- Dim swApp As SldWorks.SldWorks
1 A5 U i) V7 X7 [- @2 g - Dim swFilter As String, fileName As String, fileConfig As String, fileDispName As String
! b: w+ r3 F, W - Dim fileOptions As Long8 B0 y8 L4 D- {
- * d8 s" O) q9 V" s# S6 p1 Z! a
- Sub main()
: Q9 M1 a8 U: f8 k1 q2 V) n - Set swApp = Application.SldWorks' F e: h$ {+ g/ i- w! F
- swFilter = "All(*.*)|*.*": ~+ ]" k. d# ~/ L" U, W
- 2 Y7 D3 i4 d7 h/ T( O
- ' Browse and get the Selected file name
7 a& i6 N, P0 ?7 c( m - fileName = swApp.GetOpenFileName("Browse Document", "", swFilter, fileOptions, fileConfig, fileDispName)( V: C3 |, f8 ]) y
- ' Get the path of the selected file- C# @ O% Z. R& y7 N) ]
- fileName = Left(fileName, InStrRev(fileName, ""))% e4 Y& A U5 ]2 n ]
- Debug.Print fileName
7 v7 e* N4 B. I$ M1 Y/ o- @ - End Sub
- F9 S$ E( e1 K6 ?
复制代码 / R( }/ |' ^1 ~
2 u/ j, v& A4 i/ P0 K$ y
|
|