Ativar macro somente em um arquivo que tenha um nome específico

%3CLINGO-SUB%20id%3D%22lingo-sub-2517238%22%20slang%3D%22en-US%22%3EAtivar%20macro%20somente%20em%20um%20arquivo%20que%20tenha%20um%20nome%20espec%C3%ADfico%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2517238%22%20slang%3D%22en-US%22%3E%3CP%20class%3D%22%22%3EOl%C3%A1%20boa%20noite%20a%20todos!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETenho%20um%20arquivo%20espec%C3%ADfico%20Ex%3A%20%22alexandre.xlsm%22%20com%20algumas%20macros.%20Este%20arquivo%20ficar%C3%A1%20aberto%20o%20dia%20todo%20de%20trabalho%2C%20para%20ser%20utilizado%20a%20todo%20instante.%20Este%20arquivo%20h%C3%A1%20macros%20para%20%22ocultar%20linhas%20de%20grade%2C%20ocultar%20t%C3%ADtulos%2C%20ocultar%20barra%20de%20formula%2C%20ocultar%20barra%20de%20menus%2C%20entre%20outras%22%3C%2FP%3E%3CP%3EAo%20abri%20um%20outro%20arquivo%20com%20nome%20diferente%20ele%20abre%20com%20o%20mesmo%20formato%20do%20arquivo%20que%20j%C3%A1%20estava%20aberto%20%22alexandre.xlsm%22.%20Por%C3%A9m%20n%C3%A3o%20quero%20que%20ele%20oculte%20nada%20nos%20novos%20arquivos%20que%20forem%20abertos.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EComo%20fazer%20uma%20macro%20funcionar%20em%20apenas%20um%20arquivo%20que%20tenha%20um%20nome%20espec%C3%ADfico%20que%20neste%20caso%20seria%20o%20%22alexandre.xlsm%22%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPara%20que%20outros%20arquivos%20que%20n%C3%A3o%20possuem%20nome%20%22alexandre.xlsm%22%20a%20planilha%20n%C3%A3o%20assuma%20nenhuma%20macro%20que%20n%C3%A3o%20seja%20do%20seu%20pr%C3%B3prio%20arquivo.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOu%20seja%20as%20macros%20de%20ocultar%20s%C3%B3%20funcionar%C3%A3o%20na%20planilha%20%22alexandre.xlsm%22%20em%20outras%20planilhas%20com%20nomes%20diversos%20essas%20macros%20n%C3%A3o%20ser%C3%A3o%20habilitadas%20ou%20funcionais.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAbaixo%20as%20macro%20da%20planilha.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3ESub%20Normal_Screen()%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EApplication.ExecuteExcel4Macro%20%22SHOW.TOOLBAR(%22%22Ribbon%22%22%2C%20True)%22%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EApplication.DisplayFormulaBar%20%3D%20True%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EApplication.DisplayStatusBar%20%3D%20True%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayWorkbookTabs%20%3D%20True%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayGridlines%20%3D%20True%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayHeadings%20%3D%20True%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayGridlines%20%3D%20True%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayVerticalScrollBar%20%3D%20True%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayHorizontalScrollBar%20%3D%20True%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EEnd%20Sub%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3ESub%20Full_Screen()%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EApplication.ExecuteExcel4Macro%20%22SHOW.TOOLBAR(%22%22Ribbon%22%22%2C%20False)%22%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EApplication.DisplayFormulaBar%20%3D%20False%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EApplication.DisplayStatusBar%20%3D%20False%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayWorkbookTabs%20%3D%20False%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayGridlines%20%3D%20False%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayHeadings%20%3D%20False%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayGridlines%20%3D%20False%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayVerticalScrollBar%20%3D%20False%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EActiveWindow.DisplayHorizontalScrollBar%20%3D%20False%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2517238%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

Olá boa noite a todos!

 

Tenho um arquivo específico Ex: "alexandre.xlsm" com algumas macros. Este arquivo ficará aberto o dia todo de trabalho, para ser utilizado a todo instante. Este arquivo há macros para "ocultar linhas de grade, ocultar títulos, ocultar barra de formula, ocultar barra de menus, entre outras"

Ao abri um outro arquivo com nome diferente ele abre com o mesmo formato do arquivo que já estava aberto "alexandre.xlsm". Porém não quero que ele oculte nada nos novos arquivos que forem abertos.

 

Como fazer uma macro funcionar em apenas um arquivo que tenha um nome específico que neste caso seria o "alexandre.xlsm"?

 

Para que outros arquivos que não possuem nome "alexandre.xlsm" a planilha não assuma nenhuma macro que não seja do seu próprio arquivo.

 

Ou seja as macros de ocultar só funcionarão na planilha "alexandre.xlsm" em outras planilhas com nomes diversos essas macros não serão habilitadas ou funcionais.

 

Abaixo as macro da planilha.

 

Sub Normal_Screen()

Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"", True)"

Application.DisplayFormulaBar = True

Application.DisplayStatusBar = True

ActiveWindow.DisplayWorkbookTabs = True

ActiveWindow.DisplayGridlines = True

ActiveWindow.DisplayHeadings = True

ActiveWindow.DisplayGridlines = True

ActiveWindow.DisplayVerticalScrollBar = True

ActiveWindow.DisplayHorizontalScrollBar = True

 

End Sub

Sub Full_Screen()

Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"", False)"

Application.DisplayFormulaBar = False

Application.DisplayStatusBar = False

ActiveWindow.DisplayWorkbookTabs = False

ActiveWindow.DisplayGridlines = False

ActiveWindow.DisplayHeadings = False

ActiveWindow.DisplayGridlines = False

ActiveWindow.DisplayVerticalScrollBar = False

ActiveWindow.DisplayHorizontalScrollBar = False

 

End Sub

0 Replies