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.
  • Avatar do usuário
Por SINESIOML
Posts
#15622
Boa Tarde aos colegas

Desejo uma ajuda em uma macro para salvar a planilha, sou seja "salvar como" esta planilha,,,
a macro salvaria com um nome copiado de uma celula e salvaria com uma extenção que tambem tem na célula e o local

agradeço desde já
Avatar do usuário
Por alexandrevba
Avatar
#15629
Boa tarde!!

Tente...
Código: Selecionar todos
Sub AleVBA_3132()
'Não testado
Dim fileName As String

fileName = Range("B2").Value & strClean(Range("B1").Value) & Range("B3").Value
ActiveWorkbook.SaveAs fileName:=fileName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
End Sub
Código: Selecionar todos
Function strClean(strIn As String) As String
Dim objRegex As Object
Set objRegex = CreateObject("vbscript.regexp")
With objRegex
    .Pattern = "[\[\]|\/\\:\*\?""<>]"
    .Global = True
    strClean = .Replace(strIn, vbNullString)
End With
Caso houver algum problema nos testes, tente esse:
Código: Selecionar todos
Sub AleVBA_3132V2()
'http://www.ozgrid.com
    Dim FName           As String
    Dim FPath           As String
    Dim FExtention      As String
    
    FName = ActiveWorkbook.Sheets("Plan1").Range("B1")
    FPath = ActiveWorkbook.Sheets("Plan1").Range("B2")
    FExtention = ActiveWorkbook.Sheets("Plan1").Range("B3")
    ActiveWorkbook.SaveAs Filename:=FPath & "\" & FName & FExtention
     
End Sub
Att
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