Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Run-time error using late binding

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Run-time error using late binding

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Run-time error using late binding

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Run-time error using late binding

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   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Run-time error using late binding

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Run-time error using late binding

Nope. Doesn't work for me (In visual studio 2005). Says "End of
Statement Expected"

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Run-time error using late binding

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
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
Late binding to Excel from Access causing Object error EagleOne@microsoftdiscussiongroups[_2_] Excel Discussion (Misc queries) 4 June 14th 08 12:45 AM
Late Binding Mark Excel Programming 4 October 17th 05 04:02 PM
Late Binding examples of binding excel application HeatherO Excel Programming 13 March 17th 05 08:19 AM
Late Binding help, Please Bud Dean Excel Programming 5 September 24th 04 04:31 AM
EARLY binding or LATE binding ? jason Excel Programming 6 February 26th 04 04:57 PM


All times are GMT +1. The time now is 11:51 PM.

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"