Instrução VBA Retor...
 
Notifications
Clear all

Instrução VBA Retorna o nome do arquivo

3 Posts
2 Usuários
0 Reactions
1,498 Visualizações
(@chook)
Posts: 197
Reputable Member
Topic starter
 

Bom dia a todos,

estou precisando criar uma função que retorne o nome do arquivo salvo. Ex.: msgbox nomedoarquivo & "foi salvo com sucesso".

Forte abraço!

 
Postado : 26/03/2012 5:41 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Bom dia!!
Veja se te ajuda.
Fonte: http://www.ozgrid.com/VBA/ExcelsDialogBoxes.htm

Sub RetrieveFileName()

Dim sFileName As String



	'Show the open dialog and pass the selected _

	file name to the String variable "sFileName"

	

	sFileName = Application.GetOpenFilename

	'They have cancelled.

	If sFileName = "False" Then Exit Sub

	MsgBox sFileName

End Sub
 
Postado : 26/03/2012 5:45 am
(@chook)
Posts: 197
Reputable Member
Topic starter
 

Bom dia Alexandre,

Valeu a dica, resolvido com o codigo abaixo:

Private Sub CommandButton215_Click()
Dim sFileName As String

   'Show the open dialog and pass the selected _
   file name to the String variable "sFileName"

   sFileName = Application.ThisWorkbook.Name

   'They have cancelled.

'   If sFileName = "False" Then Exit Sub

   MsgBox sFileName
   
End Sub
 
Postado : 26/03/2012 5:57 am