Hello
I am new to VBA and this forum and need a little help please.
I am supporting users that have hundreds of Excel files that upload to Oracle database using VB and we have recently moved servers so the DB name / URL / SID has changed.
To make it easy for users I create the following macro which works perfect for me using Excel 2016 but not for another user using Excel 2010 so maybe this is a simple case of change in VB syntax.
Sub UpdateVBA()
' *** Update VBA ***
Dim component As Object
For Each component In ActiveWorkbook.VBProject.VBComponents
Dim module As Object
Set module = component.CodeModule
If module.CountOfLines > 0 Then
Dim moduleText As String
moduleText = module.Lines(1, module.CountOfLines)
moduleText = Replace(moduleText, "//ebseprod.nch.com:443/", "//eurprod.nch.com:443/")
moduleText = Replace(moduleText, "C2039321.EBSEPROD", "NCHEBSDBS151.NCH.COM.EURPROD")
moduleText = Replace(moduleText, "EBSEPROD", "EURPROD")
moduleText = Replace(moduleText, "ebseprod", "eurprod")
module.DeleteLines 1, module.CountOfLines
module.AddFromString moduleText
End If
Next
End Sub
Administrator's note: Please take the time to review our rules. There aren't many, and they are all important. Our guidelines recommend code tags. I have added them for you this time because you are a new member. --6StringJazzer
User on 2010 is getting this error
Run-time error '-2147417848 (80010108)':
Method 'AddFromString' of object '_CodeModule' failed
Any help would be appreciated !
Bookmarks