第22章 应用程序部署策略
2010-01-21 13:16
197 查看
22.1 选择方式
22.1.1 我喜欢原型程序
22.1.2 使用模板重复成功操作
代码清单22.1: 实现伪模板功能
代码
'代码清单22.4: 修复工作薄的简单程序
Sub FixWorkbook(wb As Workbook)
Dim ws As Worksheet
Set ws = wb.Worksheets("Sheet1")
ws.Range("A1").Formula = "=b1+c1"
ws.Range("A2").Formula = "=b2+c2"
ws.Range("A3").Formula = "=b3+c3"
Set ws = Nothing
End Sub
Sub ProcessFileBatch()
Dim nIndex As Integer
Dim vFiles As Variant
Dim wb As Workbook
Dim bAlreadyOpen As Boolean
Dim sFile As String
On Error GoTo ErrHandler
vFiles = GetExcelFiles("")
If Not IsArray(vFiles) Then
Debug.Print ""
Exit Sub
End If
Application.ScreenUpdating = False
For nIndex = 1 To UBound(vFiles)
If IsWorkbookOpen(CStr(vFiles(nIndex))) Then
Set wb = Workbooks(GetShortName(CStr(vFiles(nIndex))))
Debug.Print "" & wb.Name
bAlreadyOpen = True
Else
Set wb = Workbooks.Open(CStr(vFiles(nIndex)), False)
Debug.Print "" & wb.Name
bAlreadyOpen = False
End If
Application.StatusBar = "" & wb.Name
FixWorkbook wb
If Not bAlreadyOpen Then
Debug.Print "" & wb.Name
wb.Close True
End If
Next
ErrHandler:
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
'代码清单6.2
Function IsWorkbookOpen(sWorkbook As String) As Boolean
End Function
'代码清单5.6
Function GetExcelFiles(sTitle As String) As Variant
End Function
'代码清单5.8
Function GetShortName(sLongName As String) As Variant
End Function
'代码清单5.8
Function BreakdownName(sFullName As String, byref sname As String, byref sPath As String) As Variant
End Function
'代码清单5.8
Function FileNamePosition(sFullName As String) As Integer
End Function
22.1.1 我喜欢原型程序
22.1.2 使用模板重复成功操作
代码清单22.1: 实现伪模板功能
代码
'代码清单22.4: 修复工作薄的简单程序
Sub FixWorkbook(wb As Workbook)
Dim ws As Worksheet
Set ws = wb.Worksheets("Sheet1")
ws.Range("A1").Formula = "=b1+c1"
ws.Range("A2").Formula = "=b2+c2"
ws.Range("A3").Formula = "=b3+c3"
Set ws = Nothing
End Sub
Sub ProcessFileBatch()
Dim nIndex As Integer
Dim vFiles As Variant
Dim wb As Workbook
Dim bAlreadyOpen As Boolean
Dim sFile As String
On Error GoTo ErrHandler
vFiles = GetExcelFiles("")
If Not IsArray(vFiles) Then
Debug.Print ""
Exit Sub
End If
Application.ScreenUpdating = False
For nIndex = 1 To UBound(vFiles)
If IsWorkbookOpen(CStr(vFiles(nIndex))) Then
Set wb = Workbooks(GetShortName(CStr(vFiles(nIndex))))
Debug.Print "" & wb.Name
bAlreadyOpen = True
Else
Set wb = Workbooks.Open(CStr(vFiles(nIndex)), False)
Debug.Print "" & wb.Name
bAlreadyOpen = False
End If
Application.StatusBar = "" & wb.Name
FixWorkbook wb
If Not bAlreadyOpen Then
Debug.Print "" & wb.Name
wb.Close True
End If
Next
ErrHandler:
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
'代码清单6.2
Function IsWorkbookOpen(sWorkbook As String) As Boolean
End Function
'代码清单5.6
Function GetExcelFiles(sTitle As String) As Variant
End Function
'代码清单5.8
Function GetShortName(sLongName As String) As Variant
End Function
'代码清单5.8
Function BreakdownName(sFullName As String, byref sname As String, byref sPath As String) As Variant
End Function
'代码清单5.8
Function FileNamePosition(sFullName As String) As Integer
End Function
相关文章推荐
- 宇宙沸腾SCCM 2012 R2系列(7)批量部署和删除msi应用程序,客户端策略周期配置
- 软件升级- 私有部署应用程序升级策略
- 实验四十八微软应用程序虚拟化之三APP-V 5.1 Client部署和通过组策略自定义配置
- 部署和应用程序没有匹配的安全区域错误
- 第二章 生成、打包、部署和管理应用程序及类型 2.2 将类型生成模块
- Exe4j和Inno setup实现Java桌面应用程序安装部署(三)
- 在VS2005 正确地创建、部署和维护由1.1迁移到ASP.NET 2.0 应用程序注意事项
- WinForm 应用程序的打包和部署_简单版(图文)
- Linux下部署tomcat及tomcat war包应用程序
- Eclipse SWT应用程序项目的打包与部署
- 在spring dm server 中部署gwt 应用程序(二)
- windows应用程序(winform窗体程序)安装部署中自定义操作出现的问题
- 部署防火墙策略的十六条守则
- 在Weblogic中部署Web应用程序
- apache2下部署node.js应用程序
- 用于 Web 应用程序项目部署的 Web.config 转换语法 【转载】
- .net应用程序的部署1
- 如果在docker中部署tomcat,并且部署java应用程序
- Win2008 R2实战之DHCP NAP策略部署 推荐
- 在IIS中部署ASP.NET 5应用程序遭遇的问题