Sabtu, 26 November 2011

[ExcelVBA] Re: Generate file name

 



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

__._,_.___
Recent Activity:
----------------------------------
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

----------------------------------
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar