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