Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi there. I previously created a different topic about this, but its
dissapeared in the mean-time, and I didnt explain myself very well anyway it seems. Basically I have a program written in VB, using Visual Basic for Applications with Excel. Now this program works fine with Excel 2003, but I get a run-time error with Excel 2000 relating to the signature of the Range.Sort method. I am not using any of the last 3 parameters, which were only added in 2003. According to what I was told previously, the dependency is somehow "recompiled" or something behind the scenes, so that if my program runs on a computer with excel 2000, it realises this and uses that. But that doesn't help explain my error. I am using late-binding for this, and I can see from the error message that my program is still trying to call Range.Sort on Excel 2000 with the parameters DataSortOption 1,2 and 3, which dont exist in 2000. I have no idea how to fix this, but i think it might be related to the use of late-binding? ************** Exception Text ************** System.Reflection.TargetParameterCountException: Number of parameters specified does not match the expected number. at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at Microsoft.Office.Interop.Excel.Range.Sort(Object Key1, XlSortOrder Order1, Object Key2, Object Type, XlSortOrder Order2, Object Key3, XlSortOrder Order3, XlYesNoGuess Header, Object OrderCustom, Object MatchCase, XlSortOrientation Orientation, XlSortMethod SortMethod, XlSortDataOption DataOption1, XlSortDataOption DataOption2, XlSortDataOption DataOption3) at exceltest.Form1.StartExcel(DateTime StartDate, DateTime EndDate, Worksheet& currentWorkSheet, Connection& Connection) at exceltest.Form1.GenerateButton_Click(Object sender, EventArgs e) at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ************** Loaded Assemblies ************** mscorlib Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.42 (RTM.050727-4200) CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll ---------------------------------------- exceltest Assembly Version: 1.0.2359.22364 Win32 Version: 1.0.2359.22364 CodeBase: file:///C:/Program%20Files/InTime%20Extractor/exceltest.exe ---------------------------------------- System.Windows.Forms Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.42 (RTM.050727-4200) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.42 (RTM.050727-4200) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Drawing Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.42 (RTM.050727-4200) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- Microsoft.VisualBasic Assembly Version: 8.0.0.0 Win32 Version: 8.0.50727.42 (RTM.050727-4200) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll ---------------------------------------- ADODB Assembly Version: 7.0.3300.0 Win32 Version: 7.10.3077 CodeBase: file:///C:/Program%20Files/InTime%20Extractor/ADODB.DLL ---------------------------------------- Microsoft.Office.Interop.Excel Assembly Version: 11.0.0.0 Win32 Version: 11.0.5530 CodeBase: file:///C:/Program%20Files/InTime%20Extractor/Microsoft.Office.Interop.Excel.DLL ---------------------------------------- Any help is really appreciated! Rohan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Better to post the code that caused the error than all that error stuff.
RBS "DaBookshah" wrote in message ups.com... Hi there. I previously created a different topic about this, but its dissapeared in the mean-time, and I didnt explain myself very well anyway it seems. Basically I have a program written in VB, using Visual Basic for Applications with Excel. Now this program works fine with Excel 2003, but I get a run-time error with Excel 2000 relating to the signature of the Range.Sort method. I am not using any of the last 3 parameters, which were only added in 2003. According to what I was told previously, the dependency is somehow "recompiled" or something behind the scenes, so that if my program runs on a computer with excel 2000, it realises this and uses that. But that doesn't help explain my error. I am using late-binding for this, and I can see from the error message that my program is still trying to call Range.Sort on Excel 2000 with the parameters DataSortOption 1,2 and 3, which dont exist in 2000. I have no idea how to fix this, but i think it might be related to the use of late-binding? ************** Exception Text ************** System.Reflection.TargetParameterCountException: Number of parameters specified does not match the expected number. at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at Microsoft.Office.Interop.Excel.Range.Sort(Object Key1, XlSortOrder Order1, Object Key2, Object Type, XlSortOrder Order2, Object Key3, XlSortOrder Order3, XlYesNoGuess Header, Object OrderCustom, Object MatchCase, XlSortOrientation Orientation, XlSortMethod SortMethod, XlSortDataOption DataOption1, XlSortDataOption DataOption2, XlSortDataOption DataOption3) at exceltest.Form1.StartExcel(DateTime StartDate, DateTime EndDate, Worksheet& currentWorkSheet, Connection& Connection) at exceltest.Form1.GenerateButton_Click(Object sender, EventArgs e) at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ************** Loaded Assemblies ************** mscorlib Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.42 (RTM.050727-4200) CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll ---------------------------------------- exceltest Assembly Version: 1.0.2359.22364 Win32 Version: 1.0.2359.22364 CodeBase: file:///C:/Program%20Files/InTime%20Extractor/exceltest.exe ---------------------------------------- System.Windows.Forms Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.42 (RTM.050727-4200) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.42 (RTM.050727-4200) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Drawing Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.42 (RTM.050727-4200) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- Microsoft.VisualBasic Assembly Version: 8.0.0.0 Win32 Version: 8.0.50727.42 (RTM.050727-4200) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll ---------------------------------------- ADODB Assembly Version: 7.0.3300.0 Win32 Version: 7.10.3077 CodeBase: file:///C:/Program%20Files/InTime%20Extractor/ADODB.DLL ---------------------------------------- Microsoft.Office.Interop.Excel Assembly Version: 11.0.0.0 Win32 Version: 11.0.5530 CodeBase: file:///C:/Program%20Files/InTime%20Extractor/Microsoft.Office.Interop.Excel.DLL ---------------------------------------- Any help is really appreciated! Rohan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ok. Thought someone might be able to make something out of the versions
on those "assemblies". But anyway. Offending line seems to be: With currentWorkSheet .Range(.Cells(4, 1), ..Cells.SpecialCells(Excel.XlCellType.xlCellTypeLa stCell)).Sort(.Cells(4, 1), Excel.XlSortOrder.xlAscending, , , , , , Excel.XlYesNoGuess.xlNo, 1, False, Excel.XlSortOrientation.xlSortColumns) End With |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That doesn't look very normal to me.
How about record your sort in a macro and post that or explain what sort you want to do? RBS "DaBookshah" wrote in message oups.com... Ok. Thought someone might be able to make something out of the versions on those "assemblies". But anyway. Offending line seems to be: With currentWorkSheet .Range(.Cells(4, 1), .Cells.SpecialCells(Excel.XlCellType.xlCellTypeLas tCell)).Sort(.Cells(4, 1), Excel.XlSortOrder.xlAscending, , , , , , Excel.XlYesNoGuess.xlNo, 1, False, Excel.XlSortOrientation.xlSortColumns) End With |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This worked fine for me. I removed the "(" right after ".Sort" and the ")"
at the end. Some methods in Excel are funny about enclosing arguments in ( ). Some methods require the arguments in ( ) if part of an expression, otherwise the ( ) are excluded. With currentWorkSheet ..Range(.Cells(4, 1), _ .Cells.SpecialCells(Excel.XlCellType.xlCellTypeLas tCell)).Sort .Cells(4, _ 1), Excel.XlSortOrder.xlAscending, , , , , , Excel.XlYesNoGuess.xlNo, _ 1, False, Excel.XlSortOrientation.xlSortColumns End With "DaBookshah" wrote: Ok. Thought someone might be able to make something out of the versions on those "assemblies". But anyway. Offending line seems to be: With currentWorkSheet .Range(.Cells(4, 1), ..Cells.SpecialCells(Excel.XlCellType.xlCellTypeLa stCell)).Sort(.Cells(4, 1), Excel.XlSortOrder.xlAscending, , , , , , Excel.XlYesNoGuess.xlNo, 1, False, Excel.XlSortOrientation.xlSortColumns) End With |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Nope. Doesn't work for me (In visual studio 2005). Says "End of
Statement Expected" |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Only now it becomes clear that your code doesn't run from Excel VBA!
You did say VB, but many posters say that when they mean VBA. You will need to post the whole procedure, not just the sort statement. RBS DaBookshah wrote: Nope. Doesn't work for me (In visual studio 2005). Says "End of Statement Expected" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Late binding to Excel from Access causing Object error | Excel Discussion (Misc queries) | |||
Late Binding | Excel Programming | |||
Late Binding examples of binding excel application | Excel Programming | |||
Late Binding help, Please | Excel Programming | |||
EARLY binding or LATE binding ? | Excel Programming |