Alejandro - this routine was really helpful!
I added
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs (nombrefin)
at the end to save the file with the generated filename.
I still don't understand why my solution didn't work, but yours did the job.
Nice that you can help, still I dont know more than two spanish words.
Muchos gracias!
Torstein
--- Den lør 2011-11-26 skrev Alejandro Tapia <alxtapia@gmail.com>:
Fra: Alejandro Tapia <alxtapia@gmail.com>
Emne: [ExcelVBA] Re: Generate file name
Til: ExcelVBA@yahoogroups.com
Dato: Lørdag 26. november 2011 20.04
Amigo: I have created a routine for you to solve this problem. go thru this and let me know your thoughts.
only copy and paste in your spreadsheet, key some values on A1, B1 and C1 -OR NOT- anyway the final product is the chance to save the file with content of A1+B1+C1
you can check it:
http://maccbet.com/index.php?option=com_content&view=article&id=818:save-filename-with-options&catid=83:detodo-vba&Itemid=223
below too the code just copy and paste and run it.:
Private Sub guarda_arch()
'****************************************************************************+
' Code developed for Alejandro Tapia @2010
' to teach the way to save one file with options
' and show the dialog box
' You can found more information at http:\\maccbet.com my personal web site.
' Codigo desarrollado por Alejandro Tapia @2010
' para enseñar como guardar un archivo utilizando opciones
' y mostrando la ventan "guardar como"
' mas informacion en http:\\maccbet.com mi portal personal.
'******************************************************************************
' 1 ********* INICIALIZANDO VARIABLES
Dim midir, mitest, minombre, midia, mimes, miano, miext As String
'2 Poniendo valores en las variables
midir = "c:\"
minombre = "-Archivo del-"
'3 tomas los valores de los rangos que necesitas aqui CONCATENAR (A1,B1,C1)
mitest = Range("A1").Value & Range("B1").Value & Range("C1").Value
'4 Tomas la fecha en partes
' podría ser solamente:
' -> mifecha = Format(Now, "dd")& Format(Now, "mmm")& Format(Now, "yyyy")
' yo prefiero usar dia, mes y año
midia = Format(Now, "dd")
mimes = Format(Now, "mmm")
miano = Format(Now, "yyyy")
mifecha = midia + mimes + miano
miext = ".xls"
'5 declaras el nombre de archivo
miarchivo = midir + mitest + minombre + mifecha + miext
'Set Wk = Workbooks.Add
'6 abres la ventana de dialogo "Guardar Como"
NombreFin = Application.GetSaveAsFilename(miarchivo, "Excel (*.xls),*.xls")
' Listo
End Sub
[Non-text portions of this message have been removed]
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar