Why Does Common Dialog Generate A *.cfn File?
Every time I open a file with Common dialog, a *.cfn file is generated in the same folder the project/executable lives in. The *.cfn file is just text with the follwing, "\filepathfilenameame of executable.dft" Why is this happening?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
File New Common Dialog
I've seen in an application a common dialog box very similar with the Save File Common Dialog Box, but instead of the Save button it had Create button.
I want to create something similar in my app. I assume it is a parameter that I have to rename in my Common Dialog box and then call .ShowSave.
How can I rename that Button to "Create"?
Common Dialog File Name
I really hate to ask this question, but I have been searchng the form for like almost an hour and can't find the answer.
When I use commondialog1.filename it gives the full path. is there a way to justget the file name?
Thanks so much.
Parse Common Dialog File
I have a Multiselect Common dialog and I want to parse the filenames.. how do I do that ??
The filenames are separated by Nulls !!
Pls help me
Common Dialog - Open File
Is there a way where you can load .rtf .doc into a textbox? not a richtextbox?
Edit by Moderator: In the future, please start your own threads, don't dig up 2 year old threads. Thanks.
Common Dialog - Open File
would somebody PLEASE tell me why this code will not open a file. I read MikeJ's tutorial and I couldn't get it to work because I don't have a Rich textbox. Why do I need one? I'm trying to open any form from a File/Open menu. When I select the file, it goes into the window on the open dialog box but it just will not open. I've been step by step through two books and this forum for 3 hours with no luck. PLEASE HELP.
Private Sub FileOpen_Click()
CommonDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" 'This sets the filter for common dialog
CommonDialog1.ShowOpen 'Make common dialog show the open dialog
Open CommonDialog1.FileName For Input As #1
Save File With Common Dialog
How can i save a textbox with a common dialog so i can go the the place i want to save my file all i got so far is
CD1 = shot for CommonDialog1
Private Sub Command5_Click()
Get File Names From MS Common Dialog
I have used a Microsoft Common Dialog 6.0 control in my Visual Basic project with multi-select set to true. Now I need to call each file that was selected into a string that is being written to a text file. Each file name will be a new line in the text file. Not sure, but I think I need to use a Do/Loop to build this list of files. I used the "Open" method to open a file then the "Output" method to write to the file. The best method I can see to use is "Write" to amke the output to the file. But I am not sure how to iterate over the selcted files writing a new line for each file. Any help is greatly appreciated. Thank you.
Common Dialog For Opening A File But...
I want to have the Open File Common Dialog but i dont want it to open a file. I just want to save the path and file name of the file opened to a string. Is that possible.
If its not possible how would i go upon making a browse input box kind of thing to browse for a file and save the full path as a string?
Thanks for you help in advance.
Open File Without Common Dialog
How can I have a open file dialog without using the common dialog within VB6? I do not want to create a new form and open it, I want a real open file dialog.
How can I do this?
Common Dialog Predetermined File ?
hi , im taking a look at a file sender made by someone else , and they used common dialog to search for files to send , is there a way to illiminate this process and have a predetermined a file to send
im trying to make a small game that involves file sending back and forth , and would like to assign a command button for each of these predermined files within the game
so say the the file locations would be:
instead of using common dialog to find them , id like to have something easier like
Private Sub Command1_Click()
send file C:Program FilesOpForAnimations1
im such a noob , and im sorry for that , i just want a predetermined location rather than using common dialog manually if thats possible
Common Dialog And File Type
is there a way i can configure the common dialog to restrict the types of files. for example, i only need .txt files, only txt files will be shown instead of all.
Input A File From A Common Dialog Box
I am trying to Input a file from a common Dialog box but I am not sure of the code up to a certain point. Here is my code:
private Sub cmdEndprogram_Click()
Dim intResponse as Integer
Const conPrompt as string = "Are you sure?"
Const conTitle as string = "Quit?"
intResponse = MsgBox(conPrompt, vbYesNo + vbQuestion, conTitle)
If intResponse = vbYes then
private Sub Form_Load()
Dim problemNumber as Integer, name as string
Dim title1 as string, problemNumber1 as Integer
Dim prompt as string, title as string, question as string
Dim answer1 as string, answer2 as string
Dim answer3 as string, number as Integer
Dim leftPos as Integer, buttonWidth as Integer
Dim ControlArray as Integer, intFileNum as Integer
Dim FileName as string
prompt = "Enter your Name."
title = "Your Name"
name = InputBox(prompt, title)
'pen "DataType Quiz.txt" for input as 1
'input #1, title1, problemNumber1
'print #2, name
'print #2, title1, problemNumber1
'get the size and position of the first button.
'leftPos = cmdDisplay(0).Left
'buttonWidth = cmdDisplay(0).Width
'Do While Not EOF(1)
'input #1, problemNumber, question, answer1, answer2, answer3, number
'picOutput.print problemNumber, question
'print #2, problemNumber, question, answer1, answer2, answer3, number
'for ControlArray = 1 to problemNumber
'leftPos = leftPos + buttonWidth + 30
'cmdDisplay(ControlArray).Left = leftPos
'cmdDisplay(ControlArray).Caption = ControlArray
'cmdDisplay(ControlArray).Visible = true
Here is the file I am trying to input. I have two other files that I have to input as well, so I have to have a control array for each question so I have a command button for each question. I guess I am just asking for a example on how I input the text file from the common dialog box into the text window, one question at a time and the control array for a button for each question.
Data-types Quiz, 8
1, What data-type would you use for the population of Chicago?, LONG,LONG,lng,1
2, What data-type would you use for a Social Security number?, STRING,STRING,str,1
3, What data-type would you use for a variable where the only valid values are ON/OFF?, BOOLEAN,BOOLEAN,bln,1
4, What data-type would you use for a constant with a value for Pi?, SINGLE,SINGLE,sng,1
5, What data-type would you use for a variable to hold the grains of sand on a beach?, DOUBLE,DOUBLE,dbl,1
6, "What initial should proceed a Public variable in a module to indicate its scope?
d. No initial", B,G,"B. g",5
7, "What initial should proceed a variable that is used in a form to indicate its scope?
d. No initial", C,M,"C. M",5
8, "What initial should proceed a variable that is used in a local procedure to indicate its scope?
d. No initial", D,NO INITIAL,"D. NO INITIAL",5
Common Dialog File Select Not Containing File Names.
i have this vb script code that i'm using in a .hta program. it basically calls a common dialog to display multiselect file list using explorer type file list.
here's the code:
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")
ObjFSO.Filter = "All Files|*.*"
ObjFSO.FilterIndex = 3
ObjFSO.InitialDir = "c:"
ObjFSO.Flags = cdlOFNAllowMultiselect or cdlOFNExplorer
InitFSO = ObjFSO.ShowOpen
selected_files = ObjFso.FileName
each_file = split(selected_files, vbnullchar)
everywhere i look at, they state that if you use this code, it should contain all the file names that you selected. but i only see the path. no file names. however if i only select one file, it will display the path and file name.
any ideas, how i can get the selected file names to show up?
Common Dialog Control To Select File The File To Use
As I am newbie at VB6 I woudl like some help on how to implement a common dialog control on my form so I can select the txt file I wish to use to bring into my array. Sorry It seems like such simple question but I would really appreciate some guidance on this? Thanks!
Input File From A Common Dialog Control
this is the code in my form:
Private Sub mnuOpen_Click()
cdlNewEmployee.Filter = "Employee Data (*.dat)|*.dat|All Files (*.*)|*.*"
cdlNewEmployee.Flags = cdlOFNHideReadOnly
cdlNewEmployee.CancelError = False
cdlNewEmployee.FileName = ""
this is the code in my module:
Public Function OpenFile()
Dim lastName As String, firstName As String, _
age As Integer, sexMale As Boolean, count As Integer
Do While EOF(1) = False
Open "EMP.DAT" For Input As #1
Input #1, lastName, firstName, age, sexMale
Call modEmployee.AddNewEmployee(lastName, firstName, age, sexMale)
when i click on the "EMP.DAT" file to be opened, a run-time error occurs saying: "bad file name or number." and it highlights the "Do While EOF(1) = False" section of my code.
what am i doing wrong?
this is the rest of the module:
' A type to store an employee record
Public Type EmployeeRecord
lastName As String
firstName As String
age As Integer
sexMale As Boolean
Dim empList() As EmployeeRecord ' the employee list
Dim numEmployees As Integer ' number of employees in the list
'Dim cdlNewEmployee As CommonDialog
Public Function GetEmployee(ByVal index As Integer) As EmployeeRecord
GetEmployee = empList(index)
Public Function GetNumEmployees() As Integer
GetNumEmployees = numEmployees
Public Sub ClearEmployeeList()
' Clear the array.
numEmployees = 0
ReDim empList(numEmployees) As EmployeeRecord
Public Sub AddNewEmployee(ByVal ln As String, _
ByVal fn As String, _
ByVal age As Integer, _
ByVal male As Boolean)
' Add a new employee record to the array.
ReDim Preserve empList(numEmployees) As EmployeeRecord
empList(numEmployees).lastName = ln
empList(numEmployees).firstName = fn
empList(numEmployees).age = age
empList(numEmployees).sexMale = male
numEmployees = numEmployees + 1
Public Function GenderCount(ByVal male As Boolean) As Integer
' Count the # of males/females.
Dim i As Integer
GenderCount = 0
For i = 0 To numEmployees - 1
If empList(i).sexMale = male Then
GenderCount = GenderCount + 1
Public Function FormatNames(ByVal lastName As String, ByVal firstName As String) As String
' Format the given last name and first name to
' the format "LASTNAME, firstname".
FormatNames = UCase(lastName) & ", " & firstName
this is the rest of the form:
Private Sub Form_Load()
' Initialize the array.
mnuSave.Enabled = False
Private Sub cmdQuit_Click()
' Terminate the program.
Private Sub cmdMale_Click()
' Count # of males.
Call MsgBox("Number of males: " & modEmployee.GenderCount(True), vbInformation)
Private Sub cmdFemale_Click()
' Count # of females
Call MsgBox("Number of females: " & modEmployee.GenderCount(False), vbInformation)
Private Sub cmdAdd_Click()
' Display a dialog box for adding a new employee
frmEmployee.Show vbModal, Me
If frmEmployee.gValidInfo Then
Call modEmployee.AddNewEmployee(frmEmployee.gLastName, _
mnuSave.Enabled = True
Private Sub cmdClear_Click()
' Clear the array.
Private Sub lstEList_Click()
' An item is selected. Retrieve employee record from list
' display data in text boxes.
Dim emp As EmployeeRecord
emp = modEmployee.GetEmployee(lstEList.ListIndex)
txtAge = emp.age
If emp.sexMale Then
txtSex = "Male"
txtSex = "Female"
Private Sub lstEList_LostFocus()
' Clear the text boxes
txtAge = ""
txtSex = ""
Private Sub UpdateList()
' Populate the information from the array to the list box.
Dim i As Integer, nEmployees As Integer, str As String
nEmployees = modEmployee.GetNumEmployees()
For i = 0 To nEmployees - 1
str = modEmployee.FormatNames(modEmployee.GetEmployee(i).lastName, _
and this is the other form:
Public gValidInfo As Boolean
Public gLastName As String
Public gFirstName As String
Public gAge As Integer
Public gSexMale As Boolean
Private Sub Form_Load()
gValidInfo = False
gLastName = ""
gFirstName = ""
gAge = 0
gSexMale = True
Private Sub cmdCancel_Click()
' Close this dialog box.
Private Sub cmdOK_Click()
' Validate input and populate the information to the form variables.
If txtFirstName = "" Then
Call MsgBox("First name cannot be empty.", vbExclamation)
If txtLastName = "" Then
Call MsgBox("Last name cannot be empty.", vbExclamation)
If txtAge = "" Then
Call MsgBox("Age cannot be empty.", vbExclamation)
gLastName = txtLastName
gFirstName = txtFirstName
gAge = Val(txtAge)
gSexMale = optMale
gValidInfo = True
Extending Common Dialog File Open
In XP when applying the cdlOFNExplorer flag I get the XP style File Open Explorer. Does anyone know of a way to send this dialog a message, or is there a Windows API that will allow me to extend the list of folders that appear on the left (currently it shows the standard My Computer, My Documents, etc). I would like to add a couple of my own - and even eliminate some of the existing ones that don't fit my application metaphor...
VB6 preferably - but .net is fine.
Common Dialog - Multiple File Selection
Does anyone know what the heck I am missing here?
cdl1.FileName = ""
cdl1.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer
Text1 = cdl1.FileName
I am just trying to get the names of multiple files using the common dialog control. When I run the code, the "Text1" field displays the path from which the files were seleced, but nothing else. However, when I pause the code and hover over the ".FileName" in the last line of code, the popup help thing-a-ma-jig displays the filenames also (what I need in to be placed in the textbox!) seperated by a square or box (I believe this is the value for a null character.
I've searched and searched, and repeatedly find that this is correct and should be working!!! Does anyone else NOT get the same results as I do?
Opening A File Using Common Dialog Or Other Method?
Have a small problem that I was hoping someone could help me out with.
I need a way (GUI) to select specific files in a single directory. The catch is that I cannot allow the user to browse the directories on the drive. The problem is, the files that need to be selected all change and at any one time the user needs to see all of the files contained in that directory before selecting the file.
For instance.....a user comes along and presses a button to open a file through some GUI based form (similar to the Common Dialog Box). All of the files are listed to choose from, but they MUST not be able to "browse" from that location. After the file is selected, processing code then occurs until the user presses the open file box button again and then this repeats.
I have been able to use the "Common Dialog Box" which provides the nice GUI interface and using the ".initDir" option I can default to the correct directory to select a file each time, but the CDB does not appear to have an option for disallowing the browsing of directories.
I guess my other option is using the "FileListBox" object but wanted some other experts to give their opinion on what might be the best method before I spend more time looking at different alternatives.
How To Let Common Dialog Check Existing File?
I am using code to save a file:
Open commondialog1.FileName For Output As #1
Write #1, "abcd"
But the commondialog1 never ask me whether that file is already existed, just directly replace the old one, how could I let it pop up the very useful msgbox to ask " the file is already existed, would you like to replace it?", thx for any help.
Also what should I set my code if the user click Cancel button on the commondialog1 (how could I know)?
Sort File By Date In Common Dialog Box
When I display file names with the cmdialog control, I 'd like to see them sorted by date, to avoid clicking on the Date header.
How can I do that?
Open File Error With Common Dialog
I have an open file button, which uses the common dialog control...
The problem is, is that the program errors if the cancel button is selected.
Please help me eliminate this annoying error?
Here is the code;
Private Sub cmdopen_Click()
Dim customer As onecustomer
txtfilename.Text = CommonDialog1.filename
filename = txtfilename.Text
Open filename For Random As #1 Len = Len(customer)
numberofrecords = LOF(1) / Len(customer)
num.Caption = numberofrecords
[Resovled]Common Dialog File Name To Textbox.
I want it so when you press a command button It opens a common dialog,(I've put the control in already) That you select a .bmp and go open and it just puts the name of the bmp into a textbox.....(With or Without the extension, it doesn't matter)
Can this be done
If you dont understand, post back
Common Dialog Control To Save A File.
I have a Command button "Attach" and a listbox "lstAttachments".
When a click the "Attach" Command button, I want to open the save common dialog control, select an existing file and if nedded, save this file in a different directory and include the entire directory and file name in the "lstAttchments". Ideally I will also like to click on the link in the " lstAttchments" and open the file from there.
So far I have the following code and it is not ready working well apart from opening the save common dialog.
Can you please help? First for me on this and have no idea how to progress.
Private Sub cmdAttach_Click()
Dim Filename As String
CommonDialog1.Flags = cdlOFNHideReadOnly
CommonDialog1.Filter = "All Files (*.*)|*.*|Word Document" & _
"(*.doc)|*.doc|Text Files (*.txt)|*.txt"
'CommonDialog1.FilterIndex = 2
CommonDialog1.Filename = Filename
CommonDialog1.CancelError = True
Common Dialog Box Won't Close Until File Done Reading
I am having a problem with VB6 in which a Common Dialog Box won't close until after a file has finished being read.
The user selects a file to read into an array using a Common Dialog Box and they choose "open". Instead of immediately shutting down the Common Dialog Box will stay open until after the file is read.
Visual Basic 6 seems to give priority to file operations and won't give the Common Dialog Box a chance to shut down before moving on and reading the file. Since the file I am trying to read is rather large the program just sits there with the Common Dialog Box open until it is done reading. The user of the program will think it has crashed.
I have also tried creating a progress bar but the Common Dialog Box stays open regardless.
Any suggestions? Thanks in advance.
Common Dialog Controll File Path
i was wondering how i can access the file path to a file selected for opening wiht a common dialog box. say i open a file called TextFile.txt in the directory C:Text Files, when i look at commondialog1.filetitle, it only shows TextFile.txt, and what i need also is the directory it came from, any help?
Save Excel File Using Common Dialog Box
I am trying to save the Excel file that I created with data using Common Dialog box. After I created the file the messagex box pops up with two options "Save As" and "View". So I would like be able to save the file when the user clicks "Save As". So the "Save As" dialog will pop up and then I can choose the destination and save the file. After this all books will be closed. If tthe user click To view the file, I would like to load my file with data in to excel.
Please help me with this one
Opening A Txt File From My Program Using Common Dialog
this is what i have in a bas:
Public Sub Save_File(Contents As String)
On Error GoTo ErrHandle:
Dim FileName As String, lFile As String
Dim NewDate As String
frm_main.CommonDialog1.Filter = "Text Files (*.info)|*.info2"
' Default Directory:
frm_main.CommonDialog1.InitDir = App.Path
' What is the "Default" Filename: Use the whole path:
frm_main.CommonDialog1.FileName = App.Path & "untitled1.info"
'Ask to overwrite if it already exsists
frm_main.CommonDialog1.flags = &H2
' Show the save box
' The Filename is what the user entered
FileName = frm_main.CommonDialog1.FileName
' if the filename contains something, save the file
If Len(FileName) > 0 Then
lFile = FreeFile
Open FileName For Output As #lFile
Print #lFile, Contents
If Err.Number = "32755" Then
'It's a Cancel Error, Just Ignore it
MsgBox "Error: " & Err.Description, vbOKOnly, "Error # " & Err.Number
i only have the save option, i need the open option, could any one make it so i can add it to the module?
Getting The File Path Out Of A Common Dialog Box (Resolved)
I've been trying to find a way of populating the URL of my hyperlink control with the file path to documents on my computer. Someone has kindly told me that I need to use a Common dialog box but I have no idea of the code I should use toget the file path out of the box when the user clicks 'OK'.
Does anyone have any suggestions?
Choosing A Folder But Not A File With Common Dialog
I want my users to be able to choose or create a folder with a common dialog. What they will do is select a folder that will become the default folder for a certain process. The common dialog showopen allows me to choose or create a folder, but it won't do anything until a file in that folder is selected. I my case, there won't be file there as it's only the folder that I want.
So how can I choose the folder and store it's path when there is no file in it?
Common Dialog Box To Read Random File
Hey Im stuck. I have to write a program that will read in files using a common dialog box, However I am getting a mismatch error. I have included the code of what I have so Far and what I have in the project. Maybe I am entering the data wrong into the folder i am reading
Jones ,Jason ,7166275519,T
Pope ,Jose ,7165854519,T
This is how the data looks in the direcotry folder in the temp file
Here is the code and the program of what i have so far.
Private Type udtLookup
strLast As String * 20
strfirst As String * 10
strnumbers As String * 10
strDeletecode As String * 1 'F= False; T = True
Dim mudtLookup As udtLookup
Private Sub cmdexit_Click()
Private Sub ReadFileIntoList()
Open dlgcommon.FileName For Random As #1 Len = Len(mudtLookup)
Do Until EOF(1)
Get #1, mudtLookup.strLast & mudtLookup.strfirst & mudtLookup.strnumbers, mudtLookup
lstdata.AddItem mudtLookup.strLast & "," & mudtLookup.strfirst & "," & mudtLookup.strnumbers
Private Sub Form_Load()
Private Sub mnuExit_Click()
Printing A File Using Common Dialog Control
I want the user to be able to use the properties the control has to offer to print a file. Let's say the user wants to print in landscape, how do i program the control to print the file in that way or whatever way the user choose along with any other options selected?
Printing A Text File Using Common Dialog
Here's another question concerning the common dialog control. How do you print text files with it? i tried to do it myself but i got stuck! please help me. thanks in advance.
ps after this post ill stop spamming about common dialog
Saving A Text File With Common Dialog
I'm making a text editor and it will be complete if i get the source code for saving a text file using the common dialog. can anyone help? this is like the last post where i asked how to open it . thanks in advance
Open A Text File With Common Dialog
how do you open a text file with the common dialog control? and how do you display it on a text box? im a newb to the common dialog control.
Open File Common Dialog Question
I'm writing a basic wordprocessor, and I'm using a common dialog box to Open a file.
Is there any way to save the name of the folder in which the selected file is located?
So the next time the app is run, and the user opens a file, that the common dialog puts the user in the folder which he used last time?
Need Help! On Common Dialog Multiple File Selection
In the words of Yoda, "Hmmm! A frustrated newbie am I! Help me you will and grateful will I be...."
I have two issues:
One: I need to setup an Open Dialog box that will allow for multiple file selection.
Two: When I make my selection of multiple files, I need it to write the filenames into a list in column format-not in a line/string.
Common Dialog And Saving To Text File
I want to use the common dialog control to allow the user to select a path, but I want to assign the filetitle myself. Am I able to disable the filename textbox and/or put in a preselected filetitle so that the user only selects the path? Or do I need to create my own file directory?
How Can I Save A Text File Using Common Dialog
One should use Freefile function when dealing with files.
This allows the program to grab the next available number
and anyone reading the code doesn't have to remember what
number was assigned to what file. this is not necessary but
leads to good coding habits and more easily read code, especially when dealing with multiple files.
Private Sub Command1_Click()
Dim intNum as Integer
intNum = Freefile
On Error Resume Next
CommonDialog1.CancelError = True
Open CommonDialog1.Filename For Output As intNum
Print #intNum, "MyText"
Common Dialog File Location Needs Changing
I have a common dialog control that I use to get a filename. This filename is used to give the picture control a location of where to find its image. I have this working fine.
However, my problem is that this picture location is stored in a database, and is then acessed by a web server. The web server reads the location (which is normally something like "C:imagesimage.gif"). This is no good for me, as this reference points to the client location, rather than the location for the server. I need both locations, eg:
1) For the picture box - "C:imagesimage.gif"
2) For the server - "\serverimagesimage.gif", or, I have also seen something like -
I would simply use some string functions to remove the "C:" and replace it with "\server", but this procedure must work across different servers, and therefore have different names - therefore I cannot hardcode the servername into the string.
Is there any way I can convert the standard file location into a more "web-based" location?
Thanks for any help in advance.
Save A File Loaded From A Common Dialog Box
I would save a file in a default directory (for example: c:Temp)
a image .jpg that is choosed and loaded by the User using a common dialog box.
Thanks in advance....it is all the day trying to find the right code, pls help me
Save File Wihout Using Common Dialog
I would like to save files without using common dialog.
I have tried using the code described below as a saving procedure. Are there any errors in the code used or should I be approaching it differently. I am using Windows Media component. Can someone help to point me in the right direction. I am lost.
Any adevise/assistance is much appreciated.
Dim strDefaultPath As String
Dim strFilename As String
Dim str As String
Dim confirm As String
strDefaultPath = "E:AAA"
strFilename = Now
str = strDefaultPath + strFilename + ".wav"
i = mciSendString("save capture " & """" & str & """", 0&, 0, 0)
confirm = MsgBox("File is saved.", vbInformation + vbOKOnly, "File Saved")
Thanks and regards.
Opening Specific File Using Common Dialog
How do I open a specific file (an access db) using the common dialog function? I presume it needs to be automatically displayed in the file name of the open file box.
Also I want to be able to either open it at the beginning of the file or create new record by opening at the end of the file. I have created a menu with new and open for this purpose but can't find the code I need.
Thanks for looking
How To Select A File In Common Dialog Control
I want to give my user the ability to browse for any file on any drive(local or network) I found something similar in the faq section, but it only lets you select a folder, not the files inside the folder:
Its real close, but I need the common dialog control to select files, then return the absolute path and file name to the textbox.