|
Microsoft Office Application Development
|
|
The New Excel 2007 File FormatChanging properties of Form controlsI was curious how Form controls are represented in the Excel 2007 file format, so I started a journey searching for them. Demo fileI have devised a small file with this on Sheet1:
Where Form controls are storedIf you rename the xlsx file to xlsx.zip you can open the package and look inside. Open the folder xl and then the folder Worksheets. Open sheet1.xml. Near the bottom of that file, you can find this entry:
To find out what rId2 points to, open the _rels folder:
Open the sheet1.xml.rels folder and find rId2:
So now we know we need to navigate up the folder tree and find ..\xl\drawings\vmlDrawing1.vml. VML filesThere is one vmlDrawing?.vml for each worksheet that contains controls (or any other object that is captured in this vml file). According to the Open XML specification document as it was made available at ecma (look for the "mark up language reference"), VML is described as: "Vector Markup Language (VML) is an XML-based exchange, editing and delivery format for high-quality vector graphics. VML facilitates the exchange and subsequent editing of vector graphics between a wide variety of productivity and design applications. VML is based on XML 1.0, which is an open, simple, text-based language for describing structured data. " Form controls in a VML file.Drag the vml file from the explorer window on to your desktop and open the vml file. If try to you open the vml file in Internet explorer (because it so prettily colours and indents xml) you get an unpleasant surprise, IE asks you whether it should download or save the file, putting you in an endless cycle unless you choose cancel. Luckily there is a tool called "XML notepad" (free download from here), which shows the xml in various ways. Here is the tool showing the xml portion of the checkbox:
Hey! what is that font node doing up there? For over a decade I've been telling people you cannot change a form's checkboxes font. Can you? Let's just try. Changing the font of a checkbox (from the forms toolbar)Switch to the treeview tab of XML notepad (if you're using that too) and edit the font face property and the size. I changed it to: <font face="Arial Black" size="320" ..... Lets see what that did to our file. Follow these steps:
Surprise, surprise, your checkbox now looks like this:
Forms checkbox in Excel with modified font Lets stretch our luck a bit. Save the file as 97-2003 file format. Now try to open it in any of those formats (I tried 2003). Well, surprise, surprise, it sticks! Changing a control's positionThe position of control is denoted by the Anchor node inside the control's set of nodes:
So what does this mean? The first two numbers tell us where the top-left corner of the control is horizontally: the column (zero based) and the offset from the start of the left of that column. The next two numbers represent the row number (again, zero based) and the offset downwards (pixels) from the top of that row. The next four do the same for the bottom-right corner. In other words, in the xml above, the control's top-left corner is in column E, row 3. It is shifted to the right by 29 pixels. And the bottom-right corner is in cell I4, shifted 38 pixels to the right and 18 downwards, relative to that cell's top-left position. Well, that's it. I hope I have given you a head start on working with form controls in the new Excel 2007 Open XML file format. I leave it up to you to figure out what the other nodes in the vml file are for. DownloadI have made the file used in this article available for download: FeedbackSince you have managed to reach the end of this article, maybe you would care to write me a small message, expressing your opinion on this tool? Click here to write an email message to me. You may also rate this article: (Rated: 275 times, average rating: 5.8)![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
CommentsAll comments about this page: Comment by: OVGuillermo (8/27/2007 12:09:00 PM)Thank you for your site. I have found here much useful information. Good site ! ;) Comment by: Dinesh (6/25/2008 2:01:04 AM)This is pretty use ful stuff for someone who is looking to modify an existing excel tool to excel 2007. But when i try the above steps i ended up with an error saying "one of the files got corrupted" or "run time error" .. can you help me on this regard. After editing the fields required and saving it from .xmls.zip to .xmls getting a runtime error. Comment by: Jan Karel Pieterse (6/25/2008 3:06:19 AM)Hi Dinesh, When do you get these messages, when loading the file after modifications? What did you modify? Comment by: Kalpana (8/19/2008 12:43:11 PM)Thank you very much for this informative site. Though the ECMA standards have it all, its better to read such explanations of it with an example. You made my day :-) Add a comment too!!! | ||||||||||||||||||||||
|
Use the contact page to issue
questions or comments about this website. |