COMMONDIALOG BOX
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
COMMONDIALOG BOX
Ho to select/open only a file with .exp in c:\mydir\
-
- Administrator
- Posts: 78524
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78524
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: COMMONDIALOG BOX
Use something like
Code: Select all
Dim strFile As String
With CommonDialog1
.Filter = "Exp Files (*.exp)|*.exp"
.InitDir = "C:\MyDir"
.ShowOpen
If .FileName = "" Then
MsgBox "No file selected!"
Exit Sub
End If
strFile = .FileName
End With
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: COMMONDIALOG BOX
HUMMMM...HansV wrote: ↑26 Feb 2022, 15:51Use something like
Code: Select all
Dim strFile As String With CommonDialog1 .Filter = "Exp Files (*.exp)|*.exp" .InitDir = "C:\MyDir" .ShowOpen If .FileName = "" Then MsgBox "No file selected!" Exit Sub End If strFile = .FileName End With
but strFile = .FileName contain dir & filename...
in other var i need only the name of file
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: COMMONDIALOG BOX
but strFile = .FileName contain dir & filename...HansV wrote: ↑26 Feb 2022, 15:51Use something like
Code: Select all
Dim strFile As String With CommonDialog1 .Filter = "Exp Files (*.exp)|*.exp" .InitDir = "C:\MyDir" .ShowOpen If .FileName = "" Then MsgBox "No file selected!" Exit Sub End If strFile = .FileName End With
in other var i need only the name of file
-
- Administrator
- Posts: 78524
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: COMMONDIALOG BOX
Then use
Code: Select all
strFile = Mid(.FileName, InStrRev(.FileName, "\") + 1)
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: COMMONDIALOG BOX
HansV wrote: ↑26 Feb 2022, 19:01Then use
Code: Select all
strFile = Mid(.FileName, InStrRev(.FileName, "\") + 1)