Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 Matija92
		
			Matija92
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hallo everyone!
I need your help and advice. I have a macro script(VB) that changes the color of the active tab, but for each new tab I have to call it via sheet properties. I would like to ask if there is a possibility that this macro script is automatically assigned to each new and existing created TAB without me having to manually call the macro in each TAB?
 
					
				
		
 marcus_sommer
		
			marcus_sommer
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Why the macro-stuff and not just using an expression within the color-settings of the sheet? Maybe something like this:
if(subfield(GetActiveSheetId(), '\', 2) = 'SH11', red(), yellow())
whereby this expression needs to be put into each tab with determining the appropriate sheet-id.
- Marcus
 Matija92
		
			Matija92
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Thank you, but I don't want to use that command and I want to avoid entering commands manually for each tab. I wrote already a macro script that works great, but it also has to be called in each tab and i want that it happens automatically.
 
					
				
		
 marcus_sommer
		
			marcus_sommer
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		You could try to call the macro with an OnActivateSheet action whereby I would solve it with the above expression because it's very simple and fast to do - at least if it's implemented as requirement from the beginning (doing it afterwards with dozens of sheets costs of course some efforts ... even then I would use the expression).
- Marcus
 Matija92
		
			Matija92
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		The question was whether I could do it automatically. I already know about both solutions that change the color of the active tab, but I'm looking for an option that can assign it to each newly created tab automatically. Thanks.
 
					
				
		
 marcus_sommer
		
			marcus_sommer
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		I think it should be possible to set such an expression to each sheet. You could try to replace your color-setting from your macro with an expression. How to trigger it might not quite easy and will probably depend on what should in general happens and when? If you stuck with it you should take a look within the APIGuide.qvw which you could find with your install-folder by automation.
Like above already hinted I doubt that you will save with it much time. There aren't so many sheets that it make sense - you will always need to set multiple other settings to a sheet within the properties and to control if everything worked as it should ... therefore where is the benefit?
My preferred way of creating a new sheet is usually just to copy a master-sheet (or maybe a certain available sheet) to get all used properties within the new sheet, too - and just need to change the name (and if it should have different color-settings, visibilities and so on - usually not) and could create new charts.
- Marcus
.png) Brett_Bleess
		
			Brett_Bleess
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		You would need to look in the Document Properties of the app to change things for all new sheets you add, but that will only impact new sheets, not existing sheets, just FYI. One key thing to keep in mind regarding use of macros, this forces single-thread calculation condition and may be subject to timing issues causing odd calculation sequences etc., macro should be last resort when developing and there is no other means of accomplishing things...
Regards,
Brett
