Re: Calling a Excel function from VB
- From: "RB Smissaert" <bartsmissaert@xxxxxxxxxxxxxxxx>
- Date: Tue, 26 Feb 2008 20:26:48 -0000
Does it work when there is no other workbook open at all?
So, no other .xls, no .xla, no Personal.xls, just only that particular WB.
RBS
"SAL" <SAL@xxxxxxxxxxxxx> wrote in message news:%23s9ZiQLeIHA.4728@xxxxxxxxxxxxxxxxxxxxxxx
Jialiang Ge,
this application is distributed to many desktops in our company. They are all still working, just not on my pc (the developement pc). That implies that something has changed on my pc (perhaps by IT), but I can't figure out what. I tried many of the suggestions in your e-mail to no avail. I still get the same error.
What else could be causing this? BTW, there's a case statement in the procedure which opens a different spread*** file for each SELECT CASE. The others are still working. I copied and pasted the code to a public Module, as suggested, fully qualified it and still the same error.
SAL
"Jialiang Ge [MSFT]" <jialge@xxxxxxxxxxxxxxxxxxxx> wrote in message news:etENoAEeIHA.4720@xxxxxxxxxxxxxxxxxxxxxxxxxHello SAL,
From your post, my understanding on this issue is: you wonder how to fix
the issue 1004 (The macro cannot be found) in the VB client that
automates/calls an Excel macro. If I'm off base, please feel free to let me
know.
I have tested the code in your first message, and it works well on my side.
So I think the error might be caused by some configuration issues. Below I
list the points I can think of at the moment. Please have a look and let me
know if it helps.
1. The method "CopyComps" should be in a Module of the workbook.
If the method is in a sheet (Double click a sheet (e.g. Sheet1) in the
workbook's VBE view (Alt + F11), and copy & paste the method into it), the
error "1004 The macro 'CopyComps' cannot be found" will be thrown. We
should put the "CopyComps" in a module (Right click the workbook's VBA
project in VBE view, choose Insert->Module, and copy & paste the method
into it)
2. List all the macros from the workbook and see if "CopyComps" is in the
list.
Step A. make sure that VB6 Menu->Project->Preferences, "Microsoft Visual
Basic for Applications Extensibility" is checked.
Step B. Copy & Paste the following VB code right below the call of
"MyXl***.Application.Visible = True". It will MsgBox the macro name when
it finds a macro.
Dim N&, Count&, MyList(200), List$
For Each Component In MyXl***.VBProject.VBComponents
With Component.CodeModule
Count = .CountOfDeclarationLines + 1
Do Until Count >= .CountOfLines
MyList(N) = .ProcOfLine(Count, _
vbext_pk_Proc)
Count = Count + .ProcCountLines _
(.ProcOfLine(Count, vbext_pk_Proc), _
vbext_pk_Proc)
MsgBox MyList(N)
List = List & vbCr & MyList(N)
If Count < .CountOfLines Then N = N + 1
Loop
End With
N = N + 1
Next
3. Try to see if we can call the macro with fully qualified procedure name.
This has been mentioned by RB, but I notice some problem when you tried the
suggestion.
"MyXl***.Application.Run "FullProperty.xsl!CopyComps", 2,
m_XArray.UpperBound(2) - 3"
Problem 1: there seems to be a typo in the line. FullProperty.xsl ->
FullProperty.xls
Problem 2: The fully qualified name should be
FullProperty.xls!Module1.CopyComps, where Module1 is the name of the module
where CopyComps is located. Please change it to the exact name on your
side. In addition, it should be a dot ('.'), rather than a bang ('!')
following the module name.
4. According to the declaration of the MyXl*** declaration (Dim MyXl***
As Workbook), I think you are using early binding (explicitly reference the
Microsoft Excel Object Library). Please make sure that the version of Excel
object model reference by the project is exactly the same as the Office
product version installed on the running machine. For instance, Microsoft
Excel Object Library 11.0 stands for Microsoft Excel 2003.
5. We do not have the code of DoEvents and ReadyExcel which is mentioned in
the first message. If you doubt that the error may be caused by the two
methods, please paste their codes here and we will check them for you.
6. If the points above do not help, is it possible for you to send a small
and reproducible sample to my mailbox (jialge@xxxxxxxxxxxxx)? I will check
if it can run on my computer and determine if it is caused by an
environment issue.
Hope it helps.
If you have any other concerns, please feel free to let us know.
Regards,
Jialiang Ge (jialge@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support
==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- Re: Calling a Excel function from VB
- From: SAL
- Re: Calling a Excel function from VB
- References:
- Calling a Excel function from VB
- From: SAL
- RE: Calling a Excel function from VB
- From: Jialiang Ge [MSFT]
- Re: Calling a Excel function from VB
- From: SAL
- Calling a Excel function from VB
- Prev by Date: Re: Odd DCOM problem
- Next by Date: Re: Bool Function default
- Previous by thread: Re: Calling a Excel function from VB
- Next by thread: Re: Calling a Excel function from VB
- Index(es):
Loading