Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Macros Disabled


Reply
 
Thread Tools Display Modes
  #1  
Old 07-07-2012, 11:10 PM
EdHoeffner EdHoeffner is offline
Newcomer
 
Join Date: Nov 2007
Posts: 8
Default Macros Disabled


Hi

I've yet another problem which is making me crazy. This is a boiled down version of a problem, but it seems to be the smallest version of things that reproduces the problem:

Public Sub TestApplication()
Dim S As String
S = ClosingPrices("fdsf", "fdsag", "hjhk")
S = Application.Run("<WB Name>.xlsm'!TestTest", "FDF", "gfdgs", "jgfdg")
S = Application.Run("'<WB Name>.xlsm'!ClosingPrices", "FDF", "gfdgs", "jgfdg")
End Sub

Public Function TestTest(arg1 As String, arg2 As String, arg3 As String) As String
TestTest = ClosingPrices(arg1, arg2, arg3)
End Function


Public Function ClosingPrices(TxtFileName As String, WBName As String, HistoryName As String) As String


The first call to ClosingPrices works just fine and the macro runs without a problem, as does the second, but the third, calling it directly through application.run, fails at that line (stepping through) with error message 1004 "Cannot run the macro ''<WB Name>.xlsm'!ClosingPrices'. The macro may not be available in this workbook or all macros may be disabled".

I've tried with and without the workbook name in the command portion of the call, but it fails either way. Obviously, this isn't the real call to ClosingPrices, but when called with real data from this workbook, it runs correctly.

Office 2007 on xpsp3 on a new computer. This construct has been working for quite a while on 2007, though this particular function is new.

I'm completely lost. Any ideas??

Thanks!!
Reply With Quote
  #2  
Old 07-10-2012, 10:21 AM
EdHoeffner EdHoeffner is offline
Newcomer
 
Join Date: Nov 2007
Posts: 8
Default Shot myself in the foot (again)

Hi

I finally figured this out and it turns out it was a stupid problem I caused. There was a class module with the same name. Changing the function name fixed the issue. Ususally, if that's a problem, it complains about it and the rest of the ways that I tried won't work, but not in this case.

My only defense is that it was too late and too long. Sorry to have wasted everyone's time.

Ed
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->