[AccessD] More Access to Excel Help Needed

ewaldt at gdls.com ewaldt at gdls.com
Wed Sep 19 09:11:30 CDT 2007


I've been trying to narrow down the problem, and I believe I've found it. 
I commented out the line that calls a module that I use to copy a module 
from my Access database to the Excel workbook. Then I put a breakpoint in 
right before it, and manually copied the module into the workbook. It 
worked fine. I tried it more than once with no problem at all. The 
problem, it would seem, must be in the CopyModule module.

Can someone see a problem with the module below? I think I remember 
adapting it from an Excel-to-Excel puppy, so apparently my adaptation is 
incorrect. I don't specifically open anything from within this module, so 
it does not seem that I should close anything. Of course I could be wrong.

I send it the name of the workbook (variable = xlBook, so I send it 
xlBook.Name). "CR_Impacts" is the name of the module within Access that I 
want to copy.

As always, thanks for any and all help.

Thomas F. Ewald
Stryker Mass Properties
General Dynamics Land Systems


Sub CopyModule(strXL As String)
'Copy CR_Impacts module to Excel workbook

    Dim CodeLines As String
    Dim ModuleTocopy As VBComponent, NewModule As VBComponent
 
    Set NewModule = _
        Workbooks(strXL).VBProject.VBComponents.Add(vbext_ct_StdModule)
    Set ModuleTocopy = _
        Application.VBE.ActiveVBProject.VBComponents("CR_Impacts")
 
    CodeLines = ModuleTocopy.CodeModule.Lines _
            (ModuleTocopy.CodeModule.CountOfLines)
 
    NewModule.CodeModule.AddFromString CodeLines
 
    NewModule.Name = ModuleTocopy.Name
 
End Sub




This is an e-mail from General Dynamics Land Systems. It is for the intended recipient only and may contain confidential and privileged information.  No one else may read, print, store, copy, forward or act in reliance on it or its attachments.  If you are not the intended recipient, please return this message to the sender and delete the message and any attachments from your computer. Your cooperation is appreciated.




More information about the AccessD mailing list