excel - Running a different macro or code part by different user -
i wrote macro save file onto specific url. problem macro run different users in company different levels of permission access intranet's folders. macro activated button on spreadsheet. far know have @ least 2 solutions:
- create different macros , link them different buttons(users press respective. not elegant-possibility in error)
- make vba recognise user , run specific macro or code string correct save url. i'd avoid first solution, don't know how write second.
here's entire code path in save as method:
sub test_salva() workbooks.open filename:= _ "\\share\qualita_mg\gestione documentazione\doc. tecnici- qualita'\moduli di supporto\c - controllo qualita'\mod unico.xlsm" windows("riepilogativo 2015.xlsb.xlsm").activate activesheet.range("a3").select while not isempty(activecell) activecell.offset(1, 0).select loop activecell.offset(-1, 0).select selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("af31").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("r2").select activesheet.paste windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("b5").select activesheet.paste windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("ad4").select activesheet.paste windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("ad5").select activesheet.paste application.cutcopymode = false progressivo = range("af31") nomefile = range("b5") activeworkbook.saveas filename:= _"\\share\qualita_mg\documentazione registrazione\certificati serie\2015\s - certificati tubi\" & progressivo & "-" & nomefile _ , fileformat:=xlopenxmlworkbookmacroenabled, createbackup:=false windows("riepilogativo 2015.xlsb.xlsm").activate activesheet.range("a3").select while not isempty(activecell) activecell.offset(1, 0).select loop activecell.offset(-1, 0).select variabile = selection nome = activecell.range("c1") activecell.offset(0, 2).range("a1").select activesheet.hyperlinks.add anchor:=selection, address:= _ "s%20-%20certificati%20tubi\" & variabile & "-" & nome & ".xlsm", texttodisplay:=nome activecell.offset(1, -2).range("a1").select end sub
i'd post solution issue:
sub test_salva() **if application.username = "manuela frignani" goto line1 else goto line2** **line1:** workbooks.open filename:= _ "z:\certificati serie\2015\mod unico.xlsm" windows("riepilogativo 2015.xlsb.xlsm").activate activesheet.range("a3").select while not isempty(activecell) activecell.offset(1, 0).select loop activecell.offset(-1, 0).select selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("af31").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("r2").select activesheet.paste windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("b5").select activesheet.paste windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("ad4").select activesheet.paste windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("ad5").select activesheet.paste application.cutcopymode = false progressivo = range("af31") nomefile = range("b5") activeworkbook.saveas filename:= _ "z:\certificati serie\2015\s - certificati tubi\" & progressivo & "-" & nomefile _ , fileformat:=xlopenxmlworkbookmacroenabled, createbackup:=false windows("riepilogativo 2015.xlsb.xlsm").activate activesheet.range("a3").select while not isempty(activecell) activecell.offset(1, 0).select loop activecell.offset(-1, 0).select variabile = selection nome = activecell.range("c1") activecell.offset(0, 2).range("a1").select activesheet.hyperlinks.add anchor:=selection, address:= _ "s%20-%20certificati%20tubi\" & variabile & "-" & nome & ".xlsm", texttodisplay:=nome selection.font .name = "calibri light" .size = 17.6 .strikethrough = false .superscript = false .subscript = false .outlinefont = false .shadow = false .underline = xlunderlinestylesingle .themecolor = xlthemecolorhyperlink .tintandshade = 0 .themefont = xlthemefontnone end selection.font.size = 16 selection.font.size = 14 selection.font.size = 12 selection.font.size = 11 selection.font.size = 10 selection.font.underline = xlunderlinestylenone selection.font.underline = xlunderlinestylesingle selection.font .themecolor = xlthemecolorlight1 .tintandshade = 0.499984740745262 end activecell.offset(1, -2).range("a1").select goto line3 **line2:** workbooks.open filename:= _ "\\share\qualita_mg\gestione documentazione\doc. tecnici- qualita'\moduli di supporto\c - controllo qualita'\mod unico.xlsm" windows("riepilogativo 2015.xlsb.xlsm").activate activesheet.range("a3").select while not isempty(activecell) activecell.offset(1, 0).select loop activecell.offset(-1, 0).select selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("af31").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("r2").select activesheet.paste windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("b5").select activesheet.paste windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("ad4").select activesheet.paste windows("riepilogativo 2015.xlsb.xlsm").activate activecell.offset(0, 1).range("a1").select application.cutcopymode = false selection.copy windows("mod unico.xlsm").activate sheets("ita-eng").activate range("ad5").select activesheet.paste application.cutcopymode = false progressivo = range("af31") nomefile = range("b5") activeworkbook.saveas filename:= _ "\\share\qualita_mg\documentazione registrazione\certificati serie\2015\s - certificati tubi\" & progressivo & "-" & nomefile _ , fileformat:=xlopenxmlworkbookmacroenabled, createbackup:=false windows("riepilogativo 2015.xlsb.xlsm").activate activesheet.range("a3").select while not isempty(activecell) activecell.offset(1, 0).select loop activecell.offset(-1, 0).select variabile = selection nome = activecell.range("c1") activecell.offset(0, 2).range("a1").select activesheet.hyperlinks.add anchor:=selection, address:= _ "s%20-%20certificati%20tubi\" & variabile & "-" & nome & ".xlsm", texttodisplay:=nome selection.font .name = "calibri light" .size = 17.6 .strikethrough = false .superscript = false .subscript = false .outlinefont = false .shadow = false .underline = xlunderlinestylesingle .themecolor = xlthemecolorhyperlink .tintandshade = 0 .themefont = xlthemefontnone end selection.font.size = 16 selection.font.size = 14 selection.font.size = 12 selection.font.size = 11 selection.font.size = 10 selection.font.underline = xlunderlinestylenone selection.font.underline = xlunderlinestylesingle selection.font .themecolor = xlthemecolorlight1 .tintandshade = 0.499984740745262 end activecell.offset(1, -2).range("a1").select **line3:** end sub
Comments
Post a Comment