PDA

View Full Version : how can i use this code in ams6



mgokkaya
02-18-2007, 11:44 AM
These functions let you programatically change a users Internet Explorer printing options found under IE's File | page setup menu. Specifically it changes the header, footer, and margins. This is especially useful if you are using the Web.Print action in an AMS project to print a report or other formatted document.

The CHANGEIESETTINGS accepts 6 arguments to manipulate the Header, Footer and 4 page margins.

The RESTOREIESETTINGS restores the original user specified settings.


Place this code into your Global Functions section



--***************************
-- CHANGE FOOTER, HEADER, & MARGINS
--***************************
--Changes the Header, footer, & Margin info used when printing from IE
function CHANGEIESETTINGS(Header, Footer, MarginTop, MarginBottom, MarginLeft, MarginRight)

--Get Current Registry Key Values if they exist
IEHeader = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "header", true);
IEFooter = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "footer", true);
IEMarginTop = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_top", true);
IEMarginBottom = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_bottom", true);
IEMarginLeft = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_left", true);
IEMarginRight = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_right", true);

--Set Values based on arguments of function
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "header", Header, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "footer", Footer, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_top", MarginTop, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_bottom", MarginBottom, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_left", MarginLeft, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_right", MarginRight, REG_SZ);
end


--***************************
--Restore Header, Footer, & Margins
--***************************
function RESTOREIESETTINGS()

--Restore User Header, footer, Margin values
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "header", IEHeader, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "footer", IEFooter, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_top", IEMarginTop, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_bottom", IEMarginBottom, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_left", IEMarginLeft, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_right", IEMarginRight, REG_SZ);
endHere's an example funtion call to change the headers and set margins to .5 inches



-- Change header & footer to "My Custom Header/footer" Change margins to .5 inch
CHANGEIESETTINGS("My Custom Header", "My Custom Footer", "0.50", "0.50", "0.50", "0.50")Here's the function call to restore the original header, footer, & margins


--Restore User values for Header, Footer, & Margins
RESTOREIESETTINGS()

Worm
02-18-2007, 02:18 PM
Here's a function KPSmith put together some time ago to take care of this for you.

http://www.indigorose.com/forums/showthread.php?t=7587

mgokkaya
02-18-2007, 03:06 PM
can u please help me WORM ???

i dont know how to use the code in a project...

Worm
02-18-2007, 04:02 PM
KP gave examples on how to use the functions. They are at the bottom of the post. Give it a try.

mgokkaya
02-18-2007, 04:03 PM
i dont know where to put the codes WORM

can u please give me an exmple ???

Worm
02-18-2007, 04:06 PM
Put the two functions in your global functions area. Then call the function to set your custum header just before you print, after you print, restore the originals.

mgokkaya
02-18-2007, 04:16 PM
thanks WORM i got it