Sunday 22 September 2013

How to invoke Microsoft Common dialog box dynamically using createobject

option explicit

private function OpenDialog() as String
  dim dlg as object
  on error goto  OpenDialog_Error
  set dlg=CreateObject("MSCOMDlg.Commondialog")
  if dlg is nothing then exit sub
  dlg.Filter="All Files (*.*)|*.*"
  dlg.CancelError=True
  dlg.ShowOpen
  OpenDialog=dlg.FileName
 exit sub
OpenDialog_Error:
end sub

private sub Form_Load()
    dim fileName as string
    fileName=OpenDialog()
end sub

No comments: