写入custom.xml步骤:
从Excel中读取数据并转换为xml格式的文本
然后转换编码
使用类模块CPKZip的功能,将custom.xml写入(CPKZip的写入功能下次介绍)
这里需要注意的是,如果某个Office文件没有custom.xml,除了要写入custom.xml之外,还必须在_rels/.rels文件后面,增加一条Relationship:
'写入customUI.xmlSub WriteCustomUI() Dim arr() Dim sXML As String arr = Range("A1").CurrentRegion.Value '单元格内容转换为xml文本 sXML = Array2XMLString(arr) If VBA.Len(sXML) = 0 Then MsgBox "请在单元格中设置customUI" Exit Sub End If Dim bucs2() As Byte bucs2 = sXML '转换编码 Dim bUTF8() As Byte Dim ret As String ret = ToUTF8(bucs