Código
Public Function Is_File(Ruta As String) As Boolean On Error GoTo error ' Verifica si el archivo tiene atributo de archivo o no If GetAttr(Ruta) = 32 Then Is_File = True Else Is_File = False End If Exit Function error: ' Si es una ruta inválida entonces no es un archivo Is_File = False End Function Public Function Es_String(Buffer) As Boolean ' Cuenta los carácteres eliminando espacios muertos y null bites If Len(Trim(Buffer)) > 0 Then Es_String = True Else Es_String = False End If End Function Private Sub Command1_Click() Dim Handle As Integer CommonDialog1.FileName = "" ' Muestra el cuadro de dialogo CommonDialog1.ShowOpen ' Verifica si fue cancelado o no If Not Es_String(CommonDialog1.FileName) Then Exit Sub ' Verifica si es archivo If Is_File(CommonDialog1.FileName) Then ' Verifica el archivo If MsgBox("¿Desea sobreescribir el archivo?", vbQuestion + vbOKCancel) = vbOK Then ' Elimina el archivo para asegurarse que se creará nuevo Call Kill(CommonDialog1.FileName) Else ' Llama nuevamente al commondialog Call Command1_Click ' Finaliza el Sub Exit Sub End If End If ' Procede a guardar el archivo ' Crea el handle Handle = FreeFile ' Abre el archivo Open CommonDialog1.FileName For Output As #Handle ' Escribe el contenido de text1 en el archivo Print #Handle, Text1.Text ' Cierra el handle Close #Handle End Sub
algo masomenos así.