diff -rup /data4/sles/build-source-only/ooo-build/build/oog680-m5/basctl/source/basicide/baside2.cxx basctl/source/basicide/baside2.cxx
--- /data4/sles/build-source-only/ooo-build/build/oog680-m5/basctl/source/basicide/baside2.cxx	2007-08-03 10:57:30.000000000 +0100
+++ basctl/source/basicide/baside2.cxx	2007-10-26 16:37:01.000000000 +0100
@@ -365,6 +365,8 @@ BOOL ModulWindow::BasicExecute()
 			DBG_ASSERT( xModule.Is(), "Kein Modul!" );
 			AddStatus( BASWIN_RUNNINGBASIC );
 			USHORT nStart, nEnd, nCurMethodStart = 0;
+			TextSelection aSel = GetEditView()->GetSelection();
+			nCurMethodStart = ( aSel.GetStart().GetPara() + 1 );
 			SbMethod* pMethod = 0;
 			// erstes Macro, sonst blind "Main" (ExtSearch?)
 			for ( USHORT nMacro = 0; nMacro < xModule->GetMethods()->Count(); nMacro++ )
@@ -372,16 +374,16 @@ BOOL ModulWindow::BasicExecute()
 				SbMethod* pM = (SbMethod*)xModule->GetMethods()->Get( nMacro );
 				DBG_ASSERT( pM, "Method?" );
 				pM->GetLineRange( nStart, nEnd );
-				if ( !pMethod || ( nStart < nCurMethodStart ) )
+				if (  nCurMethodStart >= nStart && nCurMethodStart <= nEnd ) 
 				{
 					pMethod = pM;
-					nCurMethodStart = nStart;
+					break;
 				}
 			}
 			if ( !pMethod )
-				pMethod = (SbMethod*)xModule->Find( String( RTL_CONSTASCII_USTRINGPARAM( "Main" ) ), SbxCLASS_METHOD );
+				return ( BasicIDE::ChooseMacro( uno::Reference< frame::XModel >(), FALSE, rtl::OUString() ).getLength() > 0 ) ? TRUE : FALSE;
 
-			if ( pMethod )
+			else
 			{
 				pMethod->SetDebugFlags( aStatus.nBasicFlags );
 				BasicDLL::SetDebugMode( TRUE );