Тема: Open file

Подскажите каким образом вызвать стандартное виндовое окно открытие файла(сохранение) из VBA

Re: Open file

Declare Function GetOpenFileName Lib "comdlg32.dll" _
     Alias "GetOpenFileNameA" (pOpenfilename As OpenFileName) As Boolean


Type OpenFileName
     lStructSize As Long
     hwndOwner As Long
     hInstance As Long
     lpstrFilter As String
     lpstrCustomFilter As Long
     nMaxCustrFilter As Long
     nFilterIndex As Long
     lpstrFile As String
     nMaxFile As Long
     lpstrFileTitle As String
     nMaxFileTitle As Long
     lpstrInitialDir As String
     lpstrTitle As String
     Flags As Long
     nFileOffset As Integer
     nFileExtension As Integer
     lpstrDefExt As String
     lCustrData As Long
     lpfnHook As Long
     lpTemplateName As Long
End Type

Public Const OFN_ALLOWMULTISELECT = &H200
Public Const OFN_CREATEPROMPT = &H2000
Public Const OFN_EXPLORER = &H80000
Public Const OFN_FILEMUSTEXIST = &H1000
Public Const OFN_HIDEREADONLY = &H4
Public Const OFN_NOCHANGEDIR = &H8
Public Const OFN_NODEREFERENCELINKS = &H100000
Public Const OFN_NONETWORKBUTTON = &H20000
Public Const OFN_NOREADONLYRETURN = &H8000
Public Const OFN_NOVALIDATE = &H100
Public Const OFN_OVERWRITEPROMPT = &H2
Public Const OFN_PATHMUSTEXIST = &H800
Public Const OFN_READONLY = &H1
Public Const OFN_SHOWHELP = &H10




'========================================================

' Îêíî äèàëîãà äëÿ âûáîòà ôàéëà "Îòêðûòü"
' íà âûõîäå :
'  èìÿ ôàéëà

Public Function FunctionOpenFileName() As String
     Dim strFile As String * 512
     Dim of As OpenFileName
     Dim F As String
     Dim p%, s%
     Dim FName As String
     of.hwndOwner = ThisDrawing.HWND
     of.hInstance = 0
     of.lpstrCustomFilter = 0
     of.nMaxCustrFilter = 0
     of.lpfnHook = 0
     of.lpTemplateName = 0
     of.lCustrData = 0
     of.lpstrFilter = "Ôàéëû ðàçìåðîâ (*.siz)" & Chr$(0) & "*.siz" & Chr$(0) '& _
        "Ôàéëû ïðîãðàìì (*.nc,*.txt)" & Chr$(0) & "*.nc;*.txt" & Chr$(0) & _
        "Ôàéëû íàñòðîåê (*.set)" & Chr$(0) & "*.set" & Chr$(0) & _
        "Âñå ôàéëû (*.*)" & Chr$(0) & "*.*" & Chr$(0) & Chr$(0)
'    of.nFilterIndex = Def
     FName = GetSetting("MainCAM", "Files", "Last")     ' ïî óìîë÷àíèþ ïîñëåäíèé îòêðûòûé / ñîõðàí¸ííûé ôàéë
     of.lpstrFile = FName & String$(512 - Len(FName), 0)
     of.nMaxFile = 511
     of.lpstrFileTitle = String$(512, 0)
     of.nMaxFileTitle = 511
     of.lpstrInitialDir = ""
     of.lpstrDefExt = ""
     of.Flags = OFN_HIDEREADONLY + OFN_FILEMUSTEXIST + OFN_PATHMUSTEXIST
     of.lStructSize = Len(of)
     If GetOpenFileName(of) Then
         p% = InStr(1, of.lpstrFile, Chr$(0))     ' ñîõðàíÿåì â ðååñòðå ïóòü è èìÿ ôàéëà äëÿ óêàçàíèÿ ïî óìîë÷àíèþ
         FName = Left(of.lpstrFile, p% - 1)
         OpenFileName = FName
         s% = InStr(1, of.lpstrFileTitle, Chr$(0))
         FName = Left(of.lpstrFileTitle, s% - 5)
         NameFileSiz = FName
         SaveSetting "MainCAM", "Files", "Last", FName
     Else
         OpenFileName = ""
         NameFileSiz = ""
     End If
End Function

Re: Open file

Îêíî äèàëîãà


эта лабуда коментарии по русски, кодировка не подхватилась

Re: Open file

Огромное спасибо.