1aabb0771SAndrew Rist'************************************************************************* 2aabb0771SAndrew Rist' 3aabb0771SAndrew Rist' Licensed to the Apache Software Foundation (ASF) under one 4aabb0771SAndrew Rist' or more contributor license agreements. See the NOTICE file 5aabb0771SAndrew Rist' distributed with this work for additional information 6aabb0771SAndrew Rist' regarding copyright ownership. The ASF licenses this file 7aabb0771SAndrew Rist' to you under the Apache License, Version 2.0 (the 8aabb0771SAndrew Rist' "License"); you may not use this file except in compliance 9aabb0771SAndrew Rist' with the License. You may obtain a copy of the License at 10aabb0771SAndrew Rist' 11aabb0771SAndrew Rist' http://www.apache.org/licenses/LICENSE-2.0 12aabb0771SAndrew Rist' 13aabb0771SAndrew Rist' Unless required by applicable law or agreed to in writing, 14aabb0771SAndrew Rist' software distributed under the License is distributed on an 15aabb0771SAndrew Rist' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16aabb0771SAndrew Rist' KIND, either express or implied. See the License for the 17aabb0771SAndrew Rist' specific language governing permissions and limitations 18aabb0771SAndrew Rist' under the License. 19aabb0771SAndrew Rist' 20aabb0771SAndrew Rist'************************************************************************* 21*4b085352Smseidel'### Support Module for running macros in Word. Excel and PowerPoint 22cdf0e10cSrcweir'### using automation 23cdf0e10cSrcweir 24cdf0e10cSrcweirCONST CDA_TITLE = "Document Analysis Run Macro" 25cdf0e10cSrcweirCONST CDA_ANALYSIS_INI = "analysis.ini" 26cdf0e10cSrcweirConst CDA_ERR_STD_DELAY = 10 27cdf0e10cSrcweirConst CDA_APPNAME_WORD = "Word" 28cdf0e10cSrcweirConst CDA_APPNAME_EXCEL = "Excel" 29*4b085352SmseidelConst CDA_APPNAME_POWERPOINT = "PowerPoint" 30cdf0e10cSrcweir 31cdf0e10cSrcweirDim daWrd 32cdf0e10cSrcweirDim daDoc 33cdf0e10cSrcweirDim daXl 34cdf0e10cSrcweirDim daWb 35cdf0e10cSrcweirDim daPP 36cdf0e10cSrcweirDim daPres 37cdf0e10cSrcweirDim daWshShell 38cdf0e10cSrcweirDim daFso 39cdf0e10cSrcweirDim daTitle 40cdf0e10cSrcweir 41cdf0e10cSrcweirdaTitle = CDA_TITLE 42cdf0e10cSrcweir 43cdf0e10cSrcweir'# Setup Scripting objects 44cdf0e10cSrcweirset daFso = WScript.CreateObject("Scripting.FileSystemObject") 45cdf0e10cSrcweirset daWshShell = Wscript.CreateObject("Wscript.Shell") 46cdf0e10cSrcweir 47cdf0e10cSrcweir 48cdf0e10cSrcweir'##### Run Macro FUNCTIONS ###### 49cdf0e10cSrcweir 50cdf0e10cSrcweir'###################### 51cdf0e10cSrcweirSub DASetTitle(newTitle) 52cdf0e10cSrcweir daTitle = newTitle 53cdf0e10cSrcweirEnd Sub 54cdf0e10cSrcweir 55cdf0e10cSrcweir'###################### 56cdf0e10cSrcweirSub DAsetupWrdServer 57cdf0e10cSrcweir 58cdf0e10cSrcweirOn Error Resume Next 59cdf0e10cSrcweir 60cdf0e10cSrcweirSet daWrd = wscript.CreateObject("Word.Application") 61cdf0e10cSrcweirIf Err.Number <> 0 Then 62cdf0e10cSrcweir DAErrMsg "Failed to create Word Automation server: " & vbLf & vbLf & "Error: " _ 63cdf0e10cSrcweir & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY 64cdf0e10cSrcweir FinalExit 65cdf0e10cSrcweirEnd If 66cdf0e10cSrcweir 67cdf0e10cSrcweirEnd Sub 68cdf0e10cSrcweir 69cdf0e10cSrcweir'###################### 70cdf0e10cSrcweirSub DAOpenWrdDriver(driver) 71cdf0e10cSrcweirDim sWordDriverDocPath 72cdf0e10cSrcweir 73cdf0e10cSrcweirOn Error Resume Next 74cdf0e10cSrcweirdaWrd.Visible = False 75cdf0e10cSrcweir 76cdf0e10cSrcweir'# Open a driver doc 77cdf0e10cSrcweirsWordDriverDocPath = daFso.GetAbsolutePathName(driver) 78cdf0e10cSrcweir'DAdiagMsg "sWordDriverDocPath : " & sWordDriverDocPath , CDIAG_STD_DELAY 79cdf0e10cSrcweir 80cdf0e10cSrcweirIf Not daFso.FileExists(sWordDriverDocPath) Then 81cdf0e10cSrcweir DAErrMsg "Driver doc does not exist: " & sWordDriverDocPath, CDA_ERR_STD_DELAY 82cdf0e10cSrcweir FinalExit 83cdf0e10cSrcweirEnd If 84cdf0e10cSrcweir 85cdf0e10cSrcweirSet daDoc = daWrd.Documents.Open(sWordDriverDocPath) 86cdf0e10cSrcweirIf Err.Number <> 0 Then 87cdf0e10cSrcweir DAErrMsg "Failed to open driver doc: " & vbLf & sWordDriverDocPath & vbLf & vbLf & "Error: " _ 88cdf0e10cSrcweir & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY 89cdf0e10cSrcweir FinalExit 90cdf0e10cSrcweirEnd If 91cdf0e10cSrcweir 92cdf0e10cSrcweirEnd Sub 93cdf0e10cSrcweir 94cdf0e10cSrcweir'###################### 95cdf0e10cSrcweirFunction DArunWrdDriver(driver, macro) 96cdf0e10cSrcweir 97cdf0e10cSrcweirOn Error Resume Next 98cdf0e10cSrcweir'# Run macro 99cdf0e10cSrcweirDArunWrdDriver = True 100cdf0e10cSrcweirdaWrd.Run ("AnalysisTool." & macro) 101cdf0e10cSrcweirIf Err.Number <> 0 Then 102cdf0e10cSrcweir DAErrMsg "Failed to run macro: " & macro & vbLf & vbLf & "Error: " _ 103cdf0e10cSrcweir & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY 104cdf0e10cSrcweir DArunWrdDriver = False 105cdf0e10cSrcweirEnd If 106cdf0e10cSrcweir 107cdf0e10cSrcweirEnd Function 108cdf0e10cSrcweir 109cdf0e10cSrcweir'###################### 110cdf0e10cSrcweirSub DAsaveWrdDriver(saveDriver) 111cdf0e10cSrcweir'DAdiagMsg "saveDriver : " & saveDriver , CDIAG_STD_DELAY 112cdf0e10cSrcweir'DAdiagMsg "Abs(saveDriver) : " & daFso.GetAbsolutePathName( saveDriver) , CDIAG_STD_DELAY 113cdf0e10cSrcweir daDoc.SaveAs daFso.GetAbsolutePathName( saveDriver) 114cdf0e10cSrcweirEnd Sub 115cdf0e10cSrcweir 116cdf0e10cSrcweir'###################### 117cdf0e10cSrcweirSub DAsetupExcelServer 118cdf0e10cSrcweir 119cdf0e10cSrcweirOn Error Resume Next 120cdf0e10cSrcweir 121cdf0e10cSrcweirSet daXl = wscript.CreateObject("Excel.Application") 122cdf0e10cSrcweirIf Err.Number <> 0 Then 123cdf0e10cSrcweir DAErrMsg "Failed to create Excel Automation server: " & vbLf & vbLf & "Error: " _ 124cdf0e10cSrcweir & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY 125cdf0e10cSrcweir FinalExit 126cdf0e10cSrcweirEnd If 127cdf0e10cSrcweir 128cdf0e10cSrcweirEnd Sub 129cdf0e10cSrcweir 130cdf0e10cSrcweir'###################### 131cdf0e10cSrcweirSub DAOpenExcelDriver(driver) 132cdf0e10cSrcweir Dim sExcelDriverDocPath 133cdf0e10cSrcweir 134cdf0e10cSrcweir On Error Resume Next 135cdf0e10cSrcweir daXl.Visible = False 136cdf0e10cSrcweir 137cdf0e10cSrcweir '# Open driver doc 138cdf0e10cSrcweir sExcelDriverDocPath = daFso.GetAbsolutePathName(driver) 139cdf0e10cSrcweir If Not daFso.FileExists(sExcelDriverDocPath) Then 140cdf0e10cSrcweir DAErrMsg "Driver doc does not exist: " & sExcelDriverDocPath, CDA_ERR_STD_DELAY 141cdf0e10cSrcweir FinalExit 142cdf0e10cSrcweir End If 143cdf0e10cSrcweir 144cdf0e10cSrcweir Set daWb = daXl.Workbooks.Open(sExcelDriverDocPath) 145cdf0e10cSrcweir If Err.Number <> 0 Then 146cdf0e10cSrcweir DAErrMsg "Failed to open driver doc: " & vbLf & sExcelDriverDocPath & vbLf & vbLf & "Error: " _ 147cdf0e10cSrcweir & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY 148cdf0e10cSrcweir FinalExit 149cdf0e10cSrcweir End If 150cdf0e10cSrcweir 151cdf0e10cSrcweirEnd Sub 152cdf0e10cSrcweir 153cdf0e10cSrcweir'###################### 154cdf0e10cSrcweirFunction DArunExcelDriver(driver, macro) 155cdf0e10cSrcweirOn Error Resume Next 156cdf0e10cSrcweir 157cdf0e10cSrcweir'# Run macro 158cdf0e10cSrcweirDArunExcelDriver = True 159cdf0e10cSrcweirdaXl.Run ("AnalysisTool." & macro) 160cdf0e10cSrcweirIf Err.Number <> 0 Then 161cdf0e10cSrcweir DAErrMsg "Failed to run macro: " & macro & vbLf & vbLf & "Error: " _ 162cdf0e10cSrcweir & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY 163cdf0e10cSrcweir DArunExcelDriver = False 164cdf0e10cSrcweirEnd If 165cdf0e10cSrcweir 166cdf0e10cSrcweirEnd Function 167cdf0e10cSrcweir 168cdf0e10cSrcweir'###################### 169cdf0e10cSrcweirSub DAsaveExcelDriver(saveDriver) 170cdf0e10cSrcweir '# Not overwritting - Excel hangs, need to remove file first 171cdf0e10cSrcweir if daFso.FileExists(daFso.GetAbsolutePathName(saveDriver)) Then 172cdf0e10cSrcweir daFso.DeleteFile(daFso.GetAbsolutePathName(saveDriver)) 173cdf0e10cSrcweir End If 174cdf0e10cSrcweir daWb.SaveAs daFso.GetAbsolutePathName(saveDriver) 175cdf0e10cSrcweirEnd Sub 176cdf0e10cSrcweir 177cdf0e10cSrcweir'###################### 178cdf0e10cSrcweirSub DAsetupPPServer 179cdf0e10cSrcweir 180cdf0e10cSrcweirOn Error Resume Next 181cdf0e10cSrcweir 182cdf0e10cSrcweirSet daPP = wscript.CreateObject("PowerPoint.Application") 183cdf0e10cSrcweirIf Err.Number <> 0 Then 184cdf0e10cSrcweir DAErrMsg "Failed to create PowerPoint Automation server: " & vbLf & vbLf & "Error: " _ 185cdf0e10cSrcweir & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY 186cdf0e10cSrcweir FinalExit 187cdf0e10cSrcweirEnd If 188cdf0e10cSrcweir 189cdf0e10cSrcweirEnd Sub 190cdf0e10cSrcweir 191cdf0e10cSrcweir'###################### 192cdf0e10cSrcweirSub DAOpenPPDriver(driver) 193cdf0e10cSrcweirDim sPPDriverDocPath 194cdf0e10cSrcweir 195cdf0e10cSrcweirOn Error Resume Next 196cdf0e10cSrcweir 197cdf0e10cSrcweir 198cdf0e10cSrcweir'# Open driver doc 199cdf0e10cSrcweirsPPDriverDocPath = daFso.GetAbsolutePathName(driver) 200cdf0e10cSrcweirIf Not daFso.FileExists(sPPDriverDocPath ) Then 201cdf0e10cSrcweir DAErrMsg "Driver doc does not exist: " & sPPDriverDocPath, CDA_ERR_STD_DELAY 202cdf0e10cSrcweir FinalExit 203cdf0e10cSrcweirEnd If 204cdf0e10cSrcweir 205cdf0e10cSrcweir 206cdf0e10cSrcweir'## MS: KB Article 155073 ## 207cdf0e10cSrcweir'# PPT7: OLE Automation Error Using Open Method 208cdf0e10cSrcweir'# MUST show the PowerPoint application window at least once before calling the Application.Presentations.Open method 209cdf0e10cSrcweirdaPP.Visible = True 210cdf0e10cSrcweirdaPP.WindowState = 2 'Minimize PowerPoint 211cdf0e10cSrcweir 212cdf0e10cSrcweirdaPP.Presentations.Open sPPDriverDocPath 213cdf0e10cSrcweirIf Err.Number <> 0 Then 214cdf0e10cSrcweir DAErrMsg "Failed to open driver doc: " & vbLf & sPPDriverDocPath & vbLf & vbLf & "Error: " _ 215cdf0e10cSrcweir & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY 216cdf0e10cSrcweir FinalExit 217cdf0e10cSrcweirEnd If 218cdf0e10cSrcweir 219cdf0e10cSrcweirset daPres = daPP.Presentations(1) 220cdf0e10cSrcweir 221cdf0e10cSrcweirEnd Sub 222cdf0e10cSrcweir 223cdf0e10cSrcweir'###################### 224cdf0e10cSrcweirFunction DArunPPDriver(driver, macro) 225cdf0e10cSrcweir 226cdf0e10cSrcweirOn Error Resume Next 227cdf0e10cSrcweir'# Run macro 228cdf0e10cSrcweirDArunPPDriver = True 229cdf0e10cSrcweirdaPP.Run (daFso.GetFileName(driver) & "!" & macro) 230cdf0e10cSrcweirIf Err.Number <> 0 Then 231cdf0e10cSrcweir DAErrMsg "Failed to run macro: " & macro & vbLf & vbLf & "Error: " _ 232cdf0e10cSrcweir & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY 233cdf0e10cSrcweir DArunPPDriver = False 234cdf0e10cSrcweirEnd If 235cdf0e10cSrcweir 236cdf0e10cSrcweirEnd Function 237cdf0e10cSrcweir 238cdf0e10cSrcweir'###################### 239cdf0e10cSrcweirSub DAsavePPDriver(saveDriver) 240cdf0e10cSrcweir daPres.SaveAs daFso.GetAbsolutePathName(saveDriver) 241cdf0e10cSrcweirEnd Sub 242cdf0e10cSrcweir 243cdf0e10cSrcweir 244cdf0e10cSrcweir'###################### 245cdf0e10cSrcweir 246cdf0e10cSrcweirSub DACloseApps() 247cdf0e10cSrcweir '# Quit apps 248cdf0e10cSrcweir On Error Resume Next 249cdf0e10cSrcweir If Not daWrd Is Nothing Then 250cdf0e10cSrcweir daDoc.Close wdDoNotSaveChanges 251cdf0e10cSrcweir daWrd.Quit 252cdf0e10cSrcweir End If 253cdf0e10cSrcweir If Not daXl Is Nothing Then 254cdf0e10cSrcweir daWb.Close False 255cdf0e10cSrcweir daXl.Quit 256cdf0e10cSrcweir End If 257cdf0e10cSrcweir If Not daPP Is Nothing Then 258cdf0e10cSrcweir daPres.Close 259cdf0e10cSrcweir daPP.Quit 260cdf0e10cSrcweir End If 261cdf0e10cSrcweir 262cdf0e10cSrcweir Set daDoc = Nothing 263cdf0e10cSrcweir Set daWb = Nothing 264cdf0e10cSrcweir Set daPres = Nothing 265cdf0e10cSrcweir 266cdf0e10cSrcweir Set daWrd = Nothing 267cdf0e10cSrcweir Set daXl = Nothing 268cdf0e10cSrcweir Set daPP = Nothing 269cdf0e10cSrcweirEnd Sub 270cdf0e10cSrcweir 271cdf0e10cSrcweir'###################### 272cdf0e10cSrcweir 273cdf0e10cSrcweirSub DACleanUp() 274cdf0e10cSrcweir '# Quit apps 275cdf0e10cSrcweir On Error Resume Next 276cdf0e10cSrcweir 277cdf0e10cSrcweir DACloseApps 278cdf0e10cSrcweir 279cdf0e10cSrcweir Set daFso = Nothing 280cdf0e10cSrcweir Set daWshShell = Nothing 281cdf0e10cSrcweirEnd Sub 282cdf0e10cSrcweir 283cdf0e10cSrcweir 284cdf0e10cSrcweir'###################### 285cdf0e10cSrcweirSub DAdiagMsg( msg, delay) 286cdf0e10cSrcweir '# WSHShell.echo: Popup if run with Wscript.exe, command line output if run with Cscript.exe 287cdf0e10cSrcweir WScript.Echo msg 288cdf0e10cSrcweir 289cdf0e10cSrcweir 'WSHShell.popup msg, delay, daTitle, 64 290cdf0e10cSrcweirEnd Sub 291cdf0e10cSrcweir 292cdf0e10cSrcweir'###################### 293cdf0e10cSrcweirSub DAErrMsg( msg, delay) 294cdf0e10cSrcweir daWshShell.Popup msg, delay, daTitle, 16 295cdf0e10cSrcweir 296cdf0e10cSrcweir 'WScript.Echo msg 297cdf0e10cSrcweirEnd Sub 298cdf0e10cSrcweir 299aabb0771SAndrew Rist 300cdf0e10cSrcweir'###################### 301cdf0e10cSrcweirSub DAVerifyAnalysisIni() 302cdf0e10cSrcweir if daFso.FileExists(daFso.GetAbsolutePathName(".\" & CDA_ANALYSIS_INI)) Then Exit Sub 303cdf0e10cSrcweir 304cdf0e10cSrcweir DAErrMsg CDA_ANALYSIS_INI & " does not exist. " & vbLf & vbLf & _ 305cdf0e10cSrcweir "You need to create it manually or use the DocAnalysisWizard to create one for you." & vbLf & _ 306cdf0e10cSrcweir "Once this is done you can rerun the Document Analysis command line.", CDA_ERR_STD_DELAY 307cdf0e10cSrcweir FinalExit 308cdf0e10cSrcweirEnd Sub 309cdf0e10cSrcweir 310cdf0e10cSrcweir'###################### 311cdf0e10cSrcweirSub DAExportFile(fileName, projectFile, app_name) 312cdf0e10cSrcweir On Error Resume Next 313cdf0e10cSrcweir 314cdf0e10cSrcweir Dim myProject 315cdf0e10cSrcweir 316cdf0e10cSrcweir '# Setup App Specifc VB Project 317cdf0e10cSrcweir Set myProject = DAgetProject(fileName, projectFile, app_name) 318cdf0e10cSrcweir 319cdf0e10cSrcweir Dim myComponent 320cdf0e10cSrcweir Set myComponent = myProject.VBComponents(projectFile) 321cdf0e10cSrcweir If Err.Number <> 0 Then 322cdf0e10cSrcweir DAErrMsg "Missing Project File [" & projectFile & "] - Path:" & vbLf & vbLf & fileName, CERR_STD_DELAY 323cdf0e10cSrcweir Set myComponent = Nothing 324cdf0e10cSrcweir Set myProject = Nothing 325cdf0e10cSrcweir FinalExit 326cdf0e10cSrcweir End If 327cdf0e10cSrcweir 328cdf0e10cSrcweir myProject.VBComponents(projectFile).Export fileName 329cdf0e10cSrcweir If Err.Number <> 0 Then 330cdf0e10cSrcweir DAErrMsg "Error exporting Project File [" & projectFile & "] - Path:" & vbLf & vbLf & fileName, CERR_STD_DELAY 331cdf0e10cSrcweir Set myComponent = Nothing 332cdf0e10cSrcweir Set myProject = Nothing 333cdf0e10cSrcweir FinalExit 334cdf0e10cSrcweir End If 335cdf0e10cSrcweir 336cdf0e10cSrcweir Set myComponent = Nothing 337cdf0e10cSrcweir Set myProject = Nothing 338cdf0e10cSrcweir 339cdf0e10cSrcweirEnd Sub 340cdf0e10cSrcweir 341cdf0e10cSrcweir'###################### 342cdf0e10cSrcweirSub DAImportFile(fileName, projectFile, app_name) 343cdf0e10cSrcweir On Error Resume Next 344cdf0e10cSrcweir 345cdf0e10cSrcweir Dim myProject 346cdf0e10cSrcweir 347cdf0e10cSrcweir '# Setup App Specifc VB Project 348cdf0e10cSrcweir Set myProject = DAgetProject(fileName, projectFile, app_name) 349cdf0e10cSrcweir 350cdf0e10cSrcweir '# Check if module already exists raise error 351cdf0e10cSrcweir Dim myComponent 352cdf0e10cSrcweir Set myComponent = myProject.VBComponents(projectFile) 353cdf0e10cSrcweir If Err.Number = 0 Then 354cdf0e10cSrcweir DAErrMsg "Duplicate Project File [" & projectFile & "] - Path:" & vbLf & vbLf & fileName, CERR_STD_DELAY 355cdf0e10cSrcweir Set myComponent = Nothing 356cdf0e10cSrcweir Set myProject = Nothing 357cdf0e10cSrcweir FinalExit 358cdf0e10cSrcweir End If 359cdf0e10cSrcweir 360cdf0e10cSrcweir '#If module not there need to clear out of index error 361cdf0e10cSrcweir Err.Clear 362cdf0e10cSrcweir 363cdf0e10cSrcweir If Not daFso.FileExists(fileName) Then 364cdf0e10cSrcweir DAErrMsg "Missing File " & fileName, CERR_STD_DELAY 365cdf0e10cSrcweir Set myComponent = Nothing 366cdf0e10cSrcweir Set myProject = Nothing 367cdf0e10cSrcweir FinalExit 368cdf0e10cSrcweir End If 369cdf0e10cSrcweir 370cdf0e10cSrcweir Call myProject.VBComponents.Import(fileName) 371cdf0e10cSrcweir 372cdf0e10cSrcweir If Err.Number <> 0 Then 373cdf0e10cSrcweir DAErrMsg "Error importing Project File [" & projectFile & "] - Path:" & vbLf & vbLf & fileName, CERR_STD_DELAY 374cdf0e10cSrcweir Set myComponent = Nothing 375cdf0e10cSrcweir Set myProject = Nothing 376cdf0e10cSrcweir FinalExit 377cdf0e10cSrcweir End If 378cdf0e10cSrcweir 379cdf0e10cSrcweir Set myComponent = Nothing 380cdf0e10cSrcweir Set myProject = Nothing 381cdf0e10cSrcweirEnd Sub 382cdf0e10cSrcweir 383cdf0e10cSrcweir'################# 384cdf0e10cSrcweir 385cdf0e10cSrcweirSub DARemoveModule(fileName, projectFile, app_name) 386cdf0e10cSrcweir On Error Resume Next 387cdf0e10cSrcweir 388cdf0e10cSrcweir Dim myProject 389cdf0e10cSrcweir 390cdf0e10cSrcweir '# Setup App Specifc VB Project 391cdf0e10cSrcweir Set myProject = DAgetProject(fileName, projectFile, app_name) 392cdf0e10cSrcweir 393cdf0e10cSrcweir '# Check if module already exists raise error 394cdf0e10cSrcweir Dim myComponent 395cdf0e10cSrcweir Set myComponent = myProject.VBComponents(projectFile) 396cdf0e10cSrcweir 397cdf0e10cSrcweir 398cdf0e10cSrcweir myProject.VBComponents.Remove myComponent 399cdf0e10cSrcweir 400cdf0e10cSrcweir If Err.Number <> 0 Then 401cdf0e10cSrcweir DAErrMsg "Error removing Project File [" & projectFile & "] - Path:" & vbLf & vbLf & fileName, CERR_STD_DELAY 402cdf0e10cSrcweir Set myComponent = Nothing 403cdf0e10cSrcweir Set myProject = Nothing 404cdf0e10cSrcweir FinalExit 405cdf0e10cSrcweir End If 406cdf0e10cSrcweir 407cdf0e10cSrcweir Set myComponent = Nothing 408cdf0e10cSrcweir Set myProject = Nothing 409cdf0e10cSrcweirEnd Sub 410cdf0e10cSrcweir 411cdf0e10cSrcweir'###################### 412cdf0e10cSrcweirFunction DAgetProject(fileName, projectFile, app_name) 413cdf0e10cSrcweir On Error Resume Next 414cdf0e10cSrcweir 415cdf0e10cSrcweir If app_name = CDA_APPNAME_WORD Then 416cdf0e10cSrcweir Set DAgetProject = daWrd.ActiveDocument.VBProject 417cdf0e10cSrcweir 418cdf0e10cSrcweir ElseIf app_name = CDA_APPNAME_EXCEL Then 419cdf0e10cSrcweir Set DAgetProject = daXl.ActiveWorkbook.VBProject 420cdf0e10cSrcweir 421cdf0e10cSrcweir ElseIf app_name = CDA_APPNAME_POWERPOINT Then 422cdf0e10cSrcweir Set DAgetProject = daPP.ActivePresentation.VBProject 423cdf0e10cSrcweir End If 424cdf0e10cSrcweir 425cdf0e10cSrcweir If Err.Number <> 0 Then 426cdf0e10cSrcweir DAErrMsg "Cannot access VBProject for Project File [" & projectFile & "] - Path:" & vbLf & vbLf & fileName, _ 427cdf0e10cSrcweir CERR_STD_DELAY 428cdf0e10cSrcweir Set DAgetProject = Nothing 429cdf0e10cSrcweir FinalExit 430cdf0e10cSrcweir End If 431cdf0e10cSrcweir 432cdf0e10cSrcweirEnd Function 433cdf0e10cSrcweir 434