Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excell automation - How to move sheet using late binding and VB.NET

I am looking for the code sample which allows to change the sheet's
position inside workbook via Excel's Move() method, using late binding
and VB.NET.
Simply I'd like to do something like this :

....

Dim Workbook As Object
Workbook = Workbooks.Open(fname)
Dim Sheets As Object
Sheets = Workbook.Worksheets
Dim Sheet1 As Object
Sheet1 = Sheets.Add()
Sheet1.Name = "A"
Dim Sheet2 As Object
Sheet2 = Sheets.Add()
Sheet2.Name = "B"
' I'd like to move sheet "B" after sheet "A"
Sheets("B").Move(???)


Zbyszek Gubrynowicz

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Excell automation - How to move sheet using late binding and VB.NET

Sheets("B").Move After:=Sheets(2)

"B" is the Sheet Name that appears on the tab, Sheets(2), (index), is the
sheet who's tab appears second from the left. That would be "A", after "B"
was added.

Mike F
wrote in message
oups.com...
I am looking for the code sample which allows to change the sheet's
position inside workbook via Excel's Move() method, using late binding
and VB.NET.
Simply I'd like to do something like this :

...

Dim Workbook As Object
Workbook = Workbooks.Open(fname)
Dim Sheets As Object
Sheets = Workbook.Worksheets
Dim Sheet1 As Object
Sheet1 = Sheets.Add()
Sheet1.Name = "A"
Dim Sheet2 As Object
Sheet2 = Sheets.Add()
Sheet2.Name = "B"
' I'd like to move sheet "B" after sheet "A"
Sheets("B").Move(???)


Zbyszek Gubrynowicz



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excell automation - How to move sheet using late binding and VB.NET

Hi Mike,

I tried to write the statement in the form suggested by you, but Visual
Studio 2003 transformed it into the form :

Sheets("B").Move(After:=Sheets(2))

It was no problem with compilation, but if the statement was executed,
the following exception was invoked by Microsoft Development
Environment:

"An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in
microsoft.visualbasic.dll
Additional information: Group member not found."


Are you sure that statement :

Sheets("B").Move After:=Sheets(2)

is legal when late binding is used.

Zbyszek Gubrynowicz

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excell automation - How to move sheet using late binding and VB.NET

Hi Mike,

I've forgotten to say, that though the exception, the sheet "B" was
moved to the position of sheet "A" (!) - the question is, what is the
reason of the exception ?


Zbyszek G.

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 examples of binding excel application HeatherO Excel Programming 13 March 17th 05 08:19 AM
Excel Automation Problem with Late Binding mflorezm Excel Programming 0 November 16th 04 06:03 PM
Late Binding Todd Huttenstine[_3_] Excel Programming 3 April 30th 04 11:01 AM
EARLY binding or LATE binding ? jason Excel Programming 6 February 26th 04 04:57 PM
DAO Late Binding? Sharqua Excel Programming 2 January 4th 04 02:05 AM


All times are GMT +1. The time now is 11:45 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"