Kalo boleh nimbrung, kebetulan saya ambil file DTS dari SQL Server, bisa
disesuaikan dengan format file yang mau diambil (txt,mdb,dll) :
Private Sub cmdOpenFile_Click()
'Open the common dialog to locate the Foodmart 2000.mdb file
' CancelError is True.
On Error GoTo ErrHandler
CommonDialog1.DefaultExt = ".dts"
' Set filters.
CommonDialog1.Filter = "DTS Package (*.dts)|*.dts"
' Specify default filter.
CommonDialog1.FilterIndex = 1
' Set Dialog flags
CommonDialog1.Flags = cdlOFNLongNames Or cdlOFNPathMustExist Or
cdlOFNFileMustExist
' Display the Open dialog box.
CommonDialog1.ShowOpen
' Call the open file procedure.
mDataSourcePath = CommonDialog1.FileName
txtSourceDataPath = mDataSourcePath
If FileExists(mDataSourcePath) Then
CmdExecute.Enabled = True
End If
Exit Sub
ErrHandler:
' User pressed Cancel button.
Exit Sub
End Sub
untuk procedure FileExists pakek win api sbb;
Public Function FileExists(FileName As String) As Boolean
'The FileExists() function returns a value
'of TRUE if the specified file exists, or
'FALSE if it doesn't.
Dim Msg As String
' Turn on error trapping so error handler responds
' if any error is detected.
On Error GoTo CheckError
FileExists = (Dir(FileName) <> "")
' Avoid executing error handler if no error occurs.
Exit Function
CheckError: ' Branch here if error occurs.
' Define constants to represent intrinsic Visual Basic error
' codes.
Const mnErrDiskNotReady = 71, mnErrDeviceUnavailable = 68
' vbExclamation, vbOK, vbCancel, vbCritical, and vbOKCancel are
'constants defined in the VBA type library.
If (err.Number = mnErrDiskNotReady) Then
Msg = "Put a floppy disk in the drive and close the door."
' Display message box with an exclamation mark icon and with
' OK and Cancel buttons.
If MsgBox(Msg, vbExclamation & vbOKCancel) = vbOK Then
Resume
Else
Resume Next
End If
ElseIf err.Number = mnErrDeviceUnavailable Then
Msg = "This drive or path does not exist: " & FileName
MsgBox Msg, vbExclamation
Resume Next
Else
Msg = "Unexpected error #" & Str(err.Number) & " occurred: " _
& err.Description
' Display message box with Stop sign icon and OK button.
MsgBox Msg, vbCritical
Stop
End If
Resume
End Function
Semoga membantu CMIIW.......
Dodik S
M T PT. CGP
Liung Hartono <[EMAIL PROTECTED]> wrote:
Untuk "menangkap" nama filenya pakai CommonDialog1.FileName (contoh : msgbox
commondialog1.filename)
Liung's
www.apktntajd.com (Ape Kate Ente Aje Deh!)
mario wrote:
>
>
> Yup udah bisa mas,,
>
> Sekalian nanya lagi ya..
>
> Pas saya udah milih file nya ok, trus munculin di MSFlexgrid nya
> bagaimana ya mas..
>
> Saya bingung..
>
> Sori kalo pertanyaannya masih nubie gini.
>
>
>
> *From:* [email protected]
> [mailto:[EMAIL PROTECTED] *On Behalf Of *Masim "Vavai" Sugianto
> *Sent:* Thursday, May 03, 2007 8:09 AM
> *To:* [email protected]
> *Subject:* Re: [Programmer-VB] [nanya] munculin kotak dialog "open file"
>
>
>
> Tambahkan control commondialog, terus gunakan method 'showopen' mas.
>
> commondialog1.showopen
>
> Vavai
>
> mario wrote:
>
> Permisi semua..
>
> Saya lagi bikin program transfer file..
>
> Bagaimana caranya ya munculin kotak open file
>
> Buat milih file mana yg akan dikirim..
>
>
>
> Trima kasih sebelumnya..
>
>
>
> Btw klo nyari di google,, keyword nya apa ya?
>
>
Wahana Programmer Groups Links
Yahoo! Groups Links
---------------------------------
Ahhh...imagining that irresistible "new car" smell?
Check outnew cars at Yahoo! Autos.