Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
Por joaodias
#22516
Pretendo criar um botão para guardar o excel com o nome de várias células.
Só consigo guardar em excel 97-2003. Gostaria de guardar em excel worksheet. Já tentei alterar o código para "FileName5 & ".xlsx" mas quando vou abrir dá-me erro "formato ou extensão do ficheiro não é válida"

Private Sub CommandButton21_Click()
Dim Path As String
Dim FileName1 As String
Dim FileName2 As String
Dim FileName3 As String
Dim FileName4 As String
Dim FileName5 As String
Path = "C:\Users\J. Dias\Desktop\doc\orçamenstos\"
FileName1 = Range("F3")
FileName2 = Range("F1")
FileName3 = Range("F2")
FileName4 = Range("I3")
FileName5 = Range("I2")
ActiveWorkbook.SaveAs Filename:=Path & FileName1 & " - " & FileName2 & " " & FileName3 & " - " & FileName4 & " " & FileName5 & ".xls", FileFormat:=xlNormal
End Sub
#22518
Experimente:
Código: Selecionar todos
ActiveWorkbook.SaveAs  ...  & FileName5 & ".xlsm", FileFormat:=52
#22523
Desculpe, como o arquivo tem macro eu imaginei que você quisesse salvar habilitado para macros.

Experimente este abaixo:
Código: Selecionar todos
Application.DisplayAlerts = False
 ActiveWorkbook.SaveAs  ...  & FileName5 & ".xlsx", FileFormat:=51
Application.DisplayAlerts = True
#23177
Estou agora com outro problema, gostaria de proibir a introdução de certos caracteres (\ / : * ? " <> |) uma vez que o Excel não aceita estes tipos de caracteres no nome. Como poderei fazer?
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord