--- sc/source/ui/vba//vbawindow.cxx	
+++ sc/source/ui/vba//vbawindow.cxx
@@ -35,6 +35,7 @@
 #include "vbawindow.hxx"
 #include "vbaworksheets.hxx"
 #include "vbaworksheet.hxx"
+#include "vbapane.hxx"
 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
 #include <com/sun/star/sheet/XSpreadsheet.hpp>
 #include <com/sun/star/container/XNamed.hpp>
@@ -92,7 +93,8 @@ public:
 		{
 			throw container::NoSuchElementException();
 		}
-		return uno::makeAny( uno::Reference< excel::XWorksheet > ( new ScVbaWorksheet( m_xContext, *(m_it++), m_xModel ) ) );
+		// #FIXME needs ThisWorkbook as parent
+		return uno::makeAny( uno::Reference< excel::XWorksheet > ( new ScVbaWorksheet( uno::Reference< vba::XHelperInterface >(), m_xContext, *(m_it++), m_xModel ) ) );
 	}
 
 
@@ -197,44 +199,21 @@ public:
 
 };
 
+ScVbaWindow::ScVbaWindow( const uno::Reference< vba::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowImpl_BASE( xParent, xContext ), m_xModel( xModel ) 
+{
+	uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+	m_xViewPane.set( xController, uno::UNO_QUERY_THROW );
+	m_xPane.set( ActivePane(), uno::UNO_QUERY_THROW );
+}
+
 
 void  
 ScVbaWindow::Scroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft, bool bLargeScroll ) throw (uno::RuntimeException)
 {
-	ScTabViewShell* pViewShell = getBestViewShell( m_xModel );	
-	if ( !pViewShell )
-	    return;
-	
-	sal_Int16 down = 0;	
-	sal_Int16 up = 0;	
-	sal_Int16 toRight = 0;	
-	sal_Int16 toLeft = 0;	
-	Down >>= down;
-	Up >>= up;
-	ToRight >>= toRight;
-	ToLeft >>= toLeft;
-	uno::Sequence< beans::PropertyValue > args1(2);
-	args1[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "By" ) );
-	args1[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Sel" ) );
-	args1[1].Value <<= false;
-	
-	SCROW totalUp = up - down;
-	SCCOL totalLeft = toLeft - toRight;
-	
-	if ( totalUp != 0 )
-	{
-		if (bLargeScroll)
-		    totalUp = totalUp * pViewShell->GetViewData()->VisibleCellsY( SC_SPLIT_BOTTOM );
-		pViewShell->ScrollLines(0, -totalUp);
-	}
-	
-	if ( totalLeft != 0 )
-	{
-		if (bLargeScroll)
-		    totalLeft = totalLeft * pViewShell->GetViewData()->VisibleCellsX( SC_SPLIT_LEFT );
-		pViewShell->ScrollLines(-totalLeft, 0);
-	}
-
+	if( bLargeScroll )
+		m_xPane->LargeScroll( Down, Up, ToRight, ToLeft );
+	else
+		m_xPane->SmallScroll( Down, Up, ToRight, ToLeft );
 }
 void SAL_CALL 
 ScVbaWindow::SmallScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException)
@@ -250,12 +229,13 @@ ScVbaWindow::LargeScroll( const uno::Any
 uno::Any SAL_CALL 
 ScVbaWindow::SelectedSheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
 {
-	uno::Reference< container::XEnumerationAccess > xEnumAccess( new SelectedSheetsEnumAccess( m_xContext, m_xModel  ) );
-	uno::Reference< excel::XWorksheets > xSheets(  new ScVbaWorksheets( m_xContext, xEnumAccess, m_xModel ) );
+	uno::Reference< container::XEnumerationAccess > xEnumAccess( new SelectedSheetsEnumAccess( mxContext, m_xModel  ) );
+	// #FIXME needs a workbook as a parent
+	uno::Reference< excel::XWorksheets > xSheets(  new ScVbaWorksheets( uno::Reference< vba::XHelperInterface >(), mxContext, xEnumAccess, m_xModel ) );
 	if ( aIndex.hasValue() )
 	{
 		uno::Reference< vba::XCollection > xColl( xSheets, uno::UNO_QUERY_THROW );
-		return xColl->Item( aIndex );	
+		return xColl->Item( aIndex, uno::Any() );	
 	}
 	return uno::makeAny( xSheets ); 	
 }
@@ -308,7 +288,7 @@ ScVbaWindow::getCaption() throw (uno::Ru
 		if ( ( nCrudLen + nCrudIndex ) == sTitle.getLength() )
 		{
 			sTitle = sTitle.copy( 0, nCrudIndex );
-			ScVbaWorkbook workbook( m_xContext, m_xModel );
+			ScVbaWorkbook workbook( uno::Reference< vba::XHelperInterface >( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
 			rtl::OUString sName = workbook.getName();
 			// rather bizare hack to make sure the name behavior
 			// is like XL
@@ -405,8 +385,6 @@ ScVbaWindow::getWindowState() throw (uno
 	SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, pViewFrame -> GetTopViewFrame() );
 	if ( pTop )
     {
-	// FOR_UPSTREAM_BUILD
-	/*
         WorkWindow* pWork = (WorkWindow*) pTop->GetTopFrame_Impl()->GetTopWindow_Impl();
         if ( pWork )
         {
@@ -415,7 +393,6 @@ ScVbaWindow::getWindowState() throw (uno
             else if (pWork -> IsMinimized())
                 nwindowState = xlMinimized;
         }
-	*/
     }
     return uno::makeAny( nwindowState );
 }
@@ -430,8 +407,6 @@ ScVbaWindow::setWindowState( const uno::
 	SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, pViewFrame -> GetTopViewFrame() );
 	if ( pTop )
     {
-	// FOR_UPSTREAM_BUILD
-	/*
         WorkWindow* pWork = (WorkWindow*) pTop->GetTopFrame_Impl()->GetTopWindow_Impl();
         if ( pWork )
         {
@@ -444,20 +419,45 @@ ScVbaWindow::setWindowState( const uno::
             else
                 throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Invalid Parameter" ) ), uno::Reference< uno::XInterface >() );
         }
-	*/
     }
 }
 
 void
 ScVbaWindow::Activate() throw (css::uno::RuntimeException)
 {
-	ScVbaWorkbook workbook( m_xContext, m_xModel );
+	ScVbaWorkbook workbook( uno::Reference< vba::XHelperInterface >( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
+
 	workbook.Activate();
 }
 
 void
 ScVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& FileName, const uno::Any& RouteWorkBook ) throw (uno::RuntimeException)
 {
-	ScVbaWorkbook workbook( m_xContext, m_xModel );
+	ScVbaWorkbook workbook( uno::Reference< vba::XHelperInterface >( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
 	workbook.Close(SaveChanges, FileName, RouteWorkBook );
 }
+
+uno::Reference< excel::XPane > 
+ScVbaWindow::ActivePane() 
+{ 
+	return new ScVbaPane( mxContext, m_xViewPane ); 
+}
+
+rtl::OUString& 
+ScVbaWindow::getServiceImplName()
+{
+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWindow") );
+	return sImplName;
+}
+
+uno::Sequence< rtl::OUString > 
+ScVbaWindow::getServiceNames()
+{
+	static uno::Sequence< rtl::OUString > aServiceNames;
+	if ( aServiceNames.getLength() == 0 )
+	{
+		aServiceNames.realloc( 1 );
+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Window" ) );
+	}
+	return aServiceNames;
+}
