Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
aozbaywf #1
Using Excel Solver through ColdFusion
Hello all,
I have an Excel document that has a macro in it. This macro uses several
solver functions. It looks like this:
Sub Blahblah()
Dim intCounter As Integer
Dim strArg1, strArg2 As String
'Lambdas <= Limits and >= 0
strArg1 = Range(Cells(3, 2), Cells(3, 1 + Range("C1").Value)).Address
strArg2 = Range(Cells(4, 2), Cells(4, 1 + Range("C1").Value)).Address
SolverAdd CellRef:=strArg1, Relation:=1, FormulaText:=strArg2
SolverAdd CellRef:=strArg1, Relation:=3, FormulaText:="0"
'Lambdas add up to 1
SolverAdd CellRef:="$CX$3", Relation:=2, FormulaText:="1"
'Nonnegativity
SolverAdd CellRef:="$I$1", Relation:=3, FormulaText:="0"
SolverOk SetCell:="$I$1", MaxMinVal:=1, ValueOf:="0", ByChange:=strArg1
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=True
End Sub
The macro runs without any problems when called within Excel. Here is my
problem: When I do the following in CF, the web page just does not do anything,
like it is in an infinite loop or sth.
<cftry>
<!--- If it exists, connect to it --->
<cfobject action="CONNECT" class="Excel.Application" name="objExcel"
type="COM">
<cfcatch>
<!--- The object doesn't exist, so create it --->
<cfobject action="CREATE" class="Excel.Application" name="objExcel"
type="COM">
</cfcatch>
</cftry>
<cfset objBooks = objExcel.Workbooks>
<cfset objBook = objBooks.Open("myfile.xls")>
<cfset objBook.Activate()>
<cfset objSheets = objBook.WorkSheets>
<cfset objSheet = objSheets.Item(Val(1))>
<cfset objSheet.Activate()>
<cftry>
<cfset objExcel.Run("Blahblah")>
<cfcatch type="any">
<cfoutput>#cfcatch.Message#</cfoutput>
</cfcatch>
</cftry>
<cfset objBook.Save()>
<cfset objBook.Close()>
<cfset objExcel.Quit()>
The page proceeeds to the next step when I comment out
SolverOk SetCell:="$I$1", MaxMinVal:=1, ValueOf:="0", ByChange:=strArg1
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=True
but it still does not seem to add the constraints. I tried to convert the
lines into a form like:
temp = SolverAdd(strArg1, 1, strArg2)
but it did not help either.
Ideas anyone?
aozbaywf Guest
-
Running ColdFusion 5.0 and ColdFusion 6.1 concurrently
Hi, this is my first post on this forum, I have tried looking but could not find a post that discussed my problem. I am wondering if it is possible... -
How to call a coldfusion function defined in other coldfusion file??
inside a.cfm, it has code fragment: <cfloop> <cfinclude template="b.cfm"> </cfloop> inside b.cfm, it has code fragment: ... -
Place Excel into table with ability to link when native Excel file is updated.
Is it possible to place an Excel file into InDesign and create a link so that any changes made later to the Excel file can be updated in InDesign? ... -
[PHP] PHP, Excel, jpgraph - can the graph be included in the Excel output?
You need a class that can create xls files with images. Or you can create a Web Archive: http://officeupdate.microsoft.com/office/webarchive.htm ... -
PHP, Excel, jpgraph - can the graph be included in the Excel output?
Good morning! I have several reports that are generated using PHP & MySQL for which I would like to include a graph using the excellent jpgraph...



Reply With Quote

