From d4aca024ba8ff204cebe7e917064d8b204a3795b Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 7 Sep 2010 18:00:19 +0200 Subject: mib19: #163433# let Application::Run find the correct document --- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'vbahelper') diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 8b0a52682ac0..cf6d655ff353 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -298,7 +298,20 @@ void SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const u ::rtl::OUString aMacroName = MacroName.trim(); if (0 == aMacroName.indexOf('!')) aMacroName = aMacroName.copy(1).trim(); - VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( getCurrentDocument() ), aMacroName ); + + uno::Reference< frame::XModel > xModel; + SbMethod* pMeth = StarBASIC::GetActiveMethod(); + if ( pMeth ) + { + SbModule* pMod = dynamic_cast< SbModule* >( pMeth->GetParent() ); + if ( pMod ) + xModel = StarBASIC::GetModelFromBasic( pMod ); + } + + if ( !xModel.is() ) + xModel = getCurrentDocument(); + + VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( xModel ), aMacroName ); if( aMacroInfo.IsResolved() ) { // handle the arguments -- cgit