-
Aug 2nd, 2024, 12:13 AM
#1
Thread Starter
PowerPoster
How can vb6 get the file format selected in openfilenameA lib "comdlg32.dll"?
I WAN'T TO SAVE FILE(NOT open file)
How can vb6 get the file format selected in the pop-up file dialog box by calling get openfilenameA lib "comdlg32.dll"?
IT'S BY AI,ERR:
Code:
Private Declare Function GetOpenFileName Lib "comdlg32.dll" (ByVal lpofn As OPENFILENAME) As Long
Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenFilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nFilterIndex As Long
nMaxFile As Long
lpstrFile As String
nFileOffset As Long
nFileExtension As Long
lpstrInitialDir As String
lpstrTitle As String
Flags As Long
lpstrDefExt As String
lPOS as Long
End Type
Private Sub OpenFileDialog()
Dim ofn As OPENFILENAME
Dim FileName As String
' ???????
ofn.lStructSize = SizeOf(ofn)
ofn.hwndOwner = Me.hWnd
ofn.lpstrFilter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|..."
ofn.lpstrFile = FileName
ofn.nMaxFile = Len(FileName) * 2
ofn.Flags = OFN_FILEMUSTEXIST Or OFN_PATHMUSTEXIST Or OFN_HIDEREADONLY
' ????
If GetOpenFileName(ofn) Then
' ?????????
MsgBox "Selected file: " & FileName
' ?????????????????.txt, .docx, ??
Dim fileExt As String
Dim fileDir As String
fileDir = Left(FileName, InStrRev(FileName, "\") - 1)
fileExt = Right(FileName, InStrRev(FileName, ".") - 1)
MsgBox "File format: " & fileExt
Else
MsgBox "Error opening file"
End If
End Sub
Last edited by xiaoyao; Aug 2nd, 2024 at 12:25 AM.
-
Aug 2nd, 2024, 12:25 AM
#2
Thread Starter
PowerPoster
Re: How can vb6 get the file format selected in openfilenameA lib "comdlg32.dll"?
call saveas("123.xls","*.doc,*.xlsx,*.pdf")
if i select *.doc
how but filename is .xls,not 123.doc
-
Aug 2nd, 2024, 03:20 PM
#3
Re: How can vb6 get the file format selected in openfilenameA lib "comdlg32.dll"?
Because you already specified the extension in the file title
-
Aug 2nd, 2024, 06:23 PM
#4
Thread Starter
PowerPoster
Re: How can vb6 get the file format selected in openfilenameA lib "comdlg32.dll"?
Can the file format only be used when it is opened, but not when it is saved?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|