Notifications
Clear all

Salvar com nome da célula - Office 365

7 Posts
3 Usuários
0 Reactions
1,084 Visualizações
(@gustavo-silva)
Posts: 29
Eminent Member
Topic starter
 

Olá pessoal!
Tentei utilizar um zilhão de macros para que, ao "salvar como", o nome do arquivo seja o texto de uma célula - sem sucesso.
Utilizo o Office 365 e não sei se existe uma incompatibilidade.

Preciso da ajuda de vocês! Agradeço antecipadamente!!!

 
Postado : 27/07/2016 6:11 am
(@wagner-morel-vidal-nobre)
Posts: 4063
Famed Member
 

gustavo.silva,

Bom dia!

Supondo que o nome do arquivo esteja na célula A1, use assim:

    ChDir ActiveWorkbook.Path
    ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "" & Range("A1").Value & ".xlsm" _
        , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
 
Postado : 27/07/2016 8:27 am
(@gustavo-silva)
Posts: 29
Eminent Member
Topic starter
 

Olá Wagner!
Este código já utilizei, mas não deu certo...

 
Postado : 27/07/2016 8:54 am
(@gustavo-silva)
Posts: 29
Eminent Member
Topic starter
 

Pessoal, estou quase lá...

Sub SaveAsName()
Dim save_as As Variant
Dim file_name As String
Dim ProgramName As String

file_name = Range("S1").Value
    ' Get the file name.
    save_as = Application.GetSaveAsFilename(Range("S1").Value, _
        FileFilter:="Excel Files,*.xlsx,All Files,*.*")
    ' See if the user canceled.
    If save_as = False Then Exit Sub
    ' Save the file with the new name.
    Application.DisplayAlerts = False
    If LCase$(Right$(save_as, 4)) <> ".xlsxm" Then
        file_name = save_as & ".xlsxm"
    End If
    ActiveWorkbook.SaveAs FileName:=save_as, FileFormat:= _
        xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    
End Sub

Porém, salva em formato Excel e não em formato com macro...

 
Postado : 27/07/2016 10:03 am
(@gustavo-silva)
Posts: 29
Eminent Member
Topic starter
 

Erro 400...

 
Postado : 27/07/2016 10:20 am
(@djunqueira)
Posts: 0
New Member
 

Vc deveria usar o controle de versão do Office.

 
Postado : 28/07/2016 12:52 am
(@gustavo-silva)
Posts: 29
Eminent Member
Topic starter
 

Resolvido...

Sub SaveBudget()
Dim save_as As Variant
Dim file_name As String
Dim ProgramName As String

file_name = Range("P1").Value

    save_as = Application.GetSaveAsFilename(Range("P1").Value, _
        FileFilter:="Excel Files,*.xlsm,All Files,*.*")

    If save_as = False Then Exit Sub

    Application.DisplayAlerts = False
    If LCase$(Right$(save_as, 4)) <> ".xlsm" Then
        file_name = save_as & ".xlsm"
    End If
    ActiveWorkbook.SaveAs filename:=save_as, FileFormat:=52, CreateBackup:=False
    
    
End Sub
 
Postado : 28/07/2016 7:22 am