1 diff --git sc/source/ui/docshell/docsh5.cxx sc/source/ui/docshell/docsh5.cxx
2 index 3b5986c..fe54573 100644
3 --- sc/source/ui/docshell/docsh5.cxx
4 +++ sc/source/ui/docshell/docsh5.cxx
8 #include <basic/sbstar.hxx>
9 +#include <basic/basmgr.hxx>
11 // defined in docfunc.cxx
12 void lcl_InsertModule( ScDocShell& rDocSh, SCTAB nTab, String& sModuleName, String& sModuleSource );
13 @@ -844,17 +845,27 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec
16 StarBASIC* pStarBASIC = GetBasic();
17 + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
18 + if ( GetBasicManager()->GetName().Len() > 0 )
20 + aLibName = GetBasicManager()->GetName();
21 + pStarBASIC = GetBasicManager()->GetLib( aLibName );
23 BOOL bVbaEnabled = pStarBASIC ? pStarBASIC->isVBAEnabled() : FALSE;
24 + SCTAB nTabToUse = nDestTab;
26 + if ( nDestTab == SC_TAB_APPEND )
27 + nTabToUse = aDocument.GetMaxTableNumber() - 1;
33 - aDocument.GetCodeName( nDestTab, sCodeName );
34 + aDocument.GetCodeName( nTabToUse, sCodeName );
35 com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = GetBasicContainer();
36 com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib;
37 if( xLibContainer.is() )
39 - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
40 com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName );
43 @@ -867,7 +878,7 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec
44 xLib->getByName( sModName ) >>= sModuleInfo;
45 sSource = sModuleInfo.ModuleSource;
47 - lcl_InsertModule( *this, nDestTab, sCodeName, sSource );
48 + lcl_InsertModule( *this, nTabToUse, sCodeName, sSource );