LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default CallByName() doesn't

CallByName() doesn't seem to be calling for me. I have no compile
errors, the method I'm trying to call is really there in the
CodeModule, but it doesn't execute when called by name.

This code snippet loops through all the components in the workbook.
For any StdModules, it looks for the Proc "savethisModule", and calls
it by name. The MsgBoxes show me that Module2 has a "savethisModule"
method and it's about to be called ... but it doesn't get called.

Note that the hardcoded call at the beginning of this snippet
(commented-out) does work.

So I suspect I'm missing something here ... any ideas?

-Christopher

Public Sub saveAllModules()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim procline As Long

' Call Module2.savethisModule

Set VBProj = ActiveWorkbook.VBProject
For Each VBComp In VBProj.VBComponents
MsgBox "VBComp.Type=" & VBComp.Type & ", Name=" & VBComp.Name
If (VBComp.Type = vbext_ct_StdModule) Then
Set CodeMod = VBComp.CodeModule
procline = 0
On Error Resume Next
procline = CodeMod.ProcBodyLine("savethisModule",
vbext_pk_Proc)
If procline 0 Then
MsgBox "calling " & "savethisModule" & _
"() in module" & VBComp.Name
Call CallByName(CodeMod, "savethisModule", VbMethod)
End If
End If
Next VBComp
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Example for VBA function - CallByname! HaHa Excel Discussion (Misc queries) 0 November 11th 06 05:04 PM
CallByName in Excel for Fill object bv0001 Excel Programming 2 October 26th 06 01:14 PM
callbyname in XL 2K and XL 2003 Doug Glancy[_6_] Excel Programming 1 December 14th 05 06:42 AM
Using CallByName for conversion function Nacho Nachev Excel Programming 3 October 26th 04 05:44 PM


All times are GMT +1. The time now is 06:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"