SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 130 | Next

Jim DeMarco

"Pro Excel 2007 VBA"

AppendFromFile _
"C:\Chapter 3\EmpDeptAdd.xml"
End Sub
Public Sub RefreshEmps()
oEmpDept.RefreshXML
End Sub
Public Sub RefreshHR()
oHREmployees.RefreshXML
End Sub
CHAPTER 3 n USING XML IN EXCEL 2007 118
Public Sub SaveEmps()
oEmpDept.SaveToFile
End Sub
Public Sub SaveEmpsNewFile()
oEmpDept.SaveToFile ??
"C:\Chapter 3\EmpDeptAddNEW.xml"
End Sub
Sub Cleanup()
Set oEmpDept = Nothing
Set oHREmployees = Nothing
End Sub
To test the code, save the workbook, and then do the following:
1. With Sheet1 active, run the GetEmpDept macro (shows Adventure Works employee
department information).
2. With Sheet 2 active, run the GetHREmployees macro (shows employee personal information).
3. With any sheet active, run the GetAdditionalEmpDeptInfo or AppendEmpDeptInfo
macro to append new data to the end of the data on Sheet1. The oEmpDept variable
knows where the data lives in the workbook due to the internal XML mapping.
4. Open the HREmployees.xml file in any text editor and modify a data element, and then
save the file.
5. Run the RefreshHR macro.
6. When the code has finished running, run the Cleanup macro to destroy both objects.
As you can see, we have simultaneous objects of the same type performing similar activities,
but each monitoring and controlling its own set of values.
Adding a Custom Ribbon to Your Workbook
Excel 2007 has a whole new XML file format that adds a lot of flexibility to your projects. One
neat thing you can do is add a custom ribbon to call your code and to hide the standard Excel
ribbons from your users.


Pages:
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142