mdmackillop
01-13-2006, 12:06 PM
Hi all,
I've 6 users each using a copy of the same workbook. Although most of the code is contained in a shared XLA file, it's a pain modifying the code in each of the books in turn. I'm looking to automate this by copying code from a source workbook (WBS) to each of the destination workbooks in turn (WBD). I'm collecting the corresponding module codenames in the array.
My problem lies in writing to the destination workbook. It crashes Excel. Any suggestions?
Trust Access to VB Project is enabled.
Regards
MD
For i = 0 To 5
With WBS.VBProject.VBComponents(arrMod(i, 0)).CodeModule
NewCode = .Lines(1, .countoflines)
End With
With WBD.VBProject.VBComponents(arrMod(i, 1)).CodeModule
'tried
.AddFromString NewCode
'and
.InsertLines 1, NewCode
End With
NewCode = ""
Next
I've 6 users each using a copy of the same workbook. Although most of the code is contained in a shared XLA file, it's a pain modifying the code in each of the books in turn. I'm looking to automate this by copying code from a source workbook (WBS) to each of the destination workbooks in turn (WBD). I'm collecting the corresponding module codenames in the array.
My problem lies in writing to the destination workbook. It crashes Excel. Any suggestions?
Trust Access to VB Project is enabled.
Regards
MD
For i = 0 To 5
With WBS.VBProject.VBComponents(arrMod(i, 0)).CodeModule
NewCode = .Lines(1, .countoflines)
End With
With WBD.VBProject.VBComponents(arrMod(i, 1)).CodeModule
'tried
.AddFromString NewCode
'and
.InsertLines 1, NewCode
End With
NewCode = ""
Next