By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,247 Members | 1,880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,247 IT Pros & Developers. It's quick & easy.

Use common dialog control to open a file

P: 21
I want to know how can i open some text file data using microsoft common dialog control.6 I know how to save text data using microsoft common dialog control.6
code are here,


Expand|Select|Wrap|Line Numbers
  1. cdlfiles.filter="files(*.srt)\*.ami"
  2. cdlfiles.DefaultExt="str"
  3. cdlfiles.dialogTitle="save str notepad file"
  4. cdlfiles.DialogTitel=cdlOFNOverwritePrompt + cdlOFNPathmustexist
  5. on Error GoTo e
  6. cdlfiles.showsave
  7. Open cdlfiles/FileName for Output As #1
  8. Print#1,Text1.Text
  9. close 1
  10. Exit Sub
  11. e:
  12. Resume Exitline
  13. Exitline:
  14. Exitsub
  15. end sub

please give me open code using microsoft common dialog control.6
Jun 19 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
Keep in mind, you don't use the common dialogue control to open, read or write a file. It is merely used to choose a file (or files). Once that has been done, then you perform the appropriate action.

Selecting a file to read is almost the same as opening it to write. You just use slightly different parameters - for example, you won't want an "overwrite?" prompt if the user chooses an existing file. More likely you would want to use the file-must-exist flag.

And I think the method to use is ShowOpen, rather than ShowSave.

Also, as I said before, it's better to paste your code rather than typing it in. Not only is it quicker and easier, but it saves others here from trying to run mis-typed code while trying to help. (Example: I've never heard of the DialogTitel property.)
Jun 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.