diff -urp basic/source/runtime/stdobj.cxx basic/source/runtime/stdobj.cxx
--- basic/source/runtime/stdobj.cxx	2006-11-21 18:09:02.000000000 +0000
+++ basic/source/runtime/stdobj.cxx	2006-11-23 17:09:46.000000000 +0000
@@ -41,6 +41,7 @@
 #include "stdobj1.hxx"
 #include "rtlproto.hxx"
 #include "sbintern.hxx"
+#include "errobject.hxx"
 
 // Das nArgs-Feld eines Tabelleneintrags ist wie folgt verschluesselt:
 // Zur Zeit wird davon ausgegangen, dass Properties keine Parameter
@@ -644,6 +645,11 @@ SbiStdObject::~SbiStdObject()
 
 SbxVariable* SbiStdObject::Find( const String& rName, SbxClassType t )
 {
+	// #TODO #FIXME hack for substituting ooo-basic Err with vba-ish
+	// ErrObject object
+	static String sErr( RTL_CONSTASCII_USTRINGPARAM("Err") );
+	if (  rName.EqualsIgnoreCaseAscii( sErr ) ) 
+		return SbxErrObject::getErrObject();
 	// Bereits eingetragen?
 	SbxVariable* pVar = SbxObject::Find( rName, t );
 	if( !pVar )
diff -urp basic/source/classes/makefile.mk basic/source/classes/makefile.mk
--- basic/source/classes/makefile.mk	2006-11-21 18:09:02.000000000 +0000
+++ basic/source/classes/makefile.mk	2006-11-22 19:50:56.000000000 +0000
@@ -49,6 +49,14 @@ ENABLE_EXCEPTIONS=TRUE
 	CDEFS+=-DENABLE_VBA
 .ENDIF
 
+ALLTAR : \
+        $(MISC)$/$(TARGET).don \
+        $(SLOTARGET)
+
+$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
+        +$(CPPUMAKER) -O$(OUT)$/inc -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
+        echo $@
+
 # --- Allgemein -----------------------------------------------------------
 
 COMMON_SLOFILES=	\
@@ -59,7 +59,8 @@ COMMON_SLOFILES=	\
 	$(SLO)$/sbintern.obj	\
 	$(SLO)$/sbunoobj.obj	\
 	$(SLO)$/propacc.obj	\
-	$(SLO)$/disas.obj
+	$(SLO)$/disas.obj \
+	$(SLO)$/errobject.obj \
 
 SLOFILES=	$(COMMON_SLOFILES)	\
 	$(SLO)$/eventatt.obj
--- /dev/null	2006-06-16 14:07:58.000000000 +0100
+++ basic/source/inc/errobject.hxx	2006-11-27 10:34:35.000000000 +0000
@@ -0,0 +1,16 @@
+#ifndef ERROBJECT_HXX
+#define ERROBJECT_HXX
+#include "sbunoobj.hxx"
+#include <org/openoffice/vba/XErrObject.hpp>
+
+
+class SbxErrObject : public SbUnoObject
+{
+	com::sun::star::uno::Reference< org::openoffice::vba::XErrObject > m_xErr;
+	SbxErrObject( const String& aName_, const com::sun::star::uno::Any& aUnoObj_ );
+	~SbxErrObject();
+public:
+	static SbxVariableRef getErrObject();
+	static com::sun::star::uno::Reference< org::openoffice::vba::XErrObject > getUnoErrObject();
+};
+#endif
--- /dev/null	2006-06-16 14:07:58.000000000 +0100
+++ basic/source/classes/errobject.cxx	2006-12-07 17:23:08.000000000 +0000
@@ -0,0 +1,179 @@
+#include "errobject.hxx"
+
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+#include "sbintern.hxx"
+#include "runtime.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::org::openoffice;
+
+typedef ::cppu::WeakImplHelper2< vba::XErrObject, script::XDefaultProperty > ErrObjectImpl_BASE;
+
+class ErrObject : public ErrObjectImpl_BASE
+{	
+	rtl::OUString m_sHelpFile;
+	rtl::OUString m_sSource;
+        rtl::OUString m_sDescription; 
+	sal_Int32 m_nNumber;
+	sal_Int32 m_nHelpContext;
+	
+public:
+	ErrObject();
+	~ErrObject();
+	// Attributes
+	virtual ::sal_Int32 SAL_CALL getNumber() throw (uno::RuntimeException);
+	virtual void SAL_CALL setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException);
+	virtual ::sal_Int32 SAL_CALL getHelpContext() throw (uno::RuntimeException);
+	virtual void SAL_CALL setHelpContext( ::sal_Int32 _helpcontext ) throw (uno::RuntimeException);
+	virtual ::rtl::OUString SAL_CALL getHelpFile() throw (uno::RuntimeException);
+	virtual void SAL_CALL setHelpFile( const ::rtl::OUString& _helpfile ) throw (uno::RuntimeException);
+	virtual ::rtl::OUString SAL_CALL getDescription() throw (uno::RuntimeException);
+	virtual void SAL_CALL setDescription( const ::rtl::OUString& _description ) throw (uno::RuntimeException);
+	virtual ::rtl::OUString SAL_CALL getSource() throw (uno::RuntimeException);
+	virtual void SAL_CALL setSource( const ::rtl::OUString& _source ) throw (uno::RuntimeException);
+	
+	// Methods
+	virtual void SAL_CALL Clear(  ) throw (uno::RuntimeException);
+	virtual void SAL_CALL Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException);
+	// XDefaultProperty	
+	virtual ::rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (uno::RuntimeException);
+};
+
+
+ErrObject::~ErrObject()
+{
+}
+
+ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0)
+{
+}
+
+sal_Int32 SAL_CALL
+ErrObject::getNumber() throw (uno::RuntimeException)
+{
+	return m_nNumber;
+}
+
+void SAL_CALL 
+ErrObject::setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException)
+{
+	m_nNumber = _number;
+
+	
+}
+
+::sal_Int32 SAL_CALL 
+ErrObject::getHelpContext() throw (uno::RuntimeException)
+{
+	return m_nHelpContext;
+}
+void SAL_CALL 
+ErrObject::setHelpContext( ::sal_Int32 _helpcontext ) throw (uno::RuntimeException)
+{
+	m_nHelpContext = _helpcontext;
+}
+
+::rtl::OUString SAL_CALL 
+ErrObject::getHelpFile() throw (uno::RuntimeException)
+{
+	return m_sHelpFile;
+}
+
+void SAL_CALL 
+ErrObject::setHelpFile( const ::rtl::OUString& _helpfile ) throw (uno::RuntimeException)
+{
+	m_sHelpFile = _helpfile;
+}
+
+::rtl::OUString SAL_CALL 
+ErrObject::getDescription() throw (uno::RuntimeException)
+{
+	return m_sDescription;
+}
+
+void SAL_CALL 
+ErrObject::setDescription( const ::rtl::OUString& _description ) throw (uno::RuntimeException)
+{
+	m_sDescription = _description;
+}
+
+::rtl::OUString SAL_CALL 
+ErrObject::getSource() throw (uno::RuntimeException)
+{
+	return m_sSource;
+}
+
+void SAL_CALL 
+ErrObject::setSource( const ::rtl::OUString& _source ) throw (uno::RuntimeException)
+{
+	m_sSource = _source;
+}
+	
+// Methods
+void SAL_CALL 
+ErrObject::Clear(  ) throw (uno::RuntimeException)
+{
+	m_sHelpFile = rtl::OUString();
+	m_sSource = m_sHelpFile;
+	m_sDescription = m_sSource;
+	m_nNumber = 0;	
+	m_nHelpContext = 0;	
+}
+
+void SAL_CALL 
+ErrObject::Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException)
+{
+	if ( !Number.hasValue() )
+		throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference< uno::XInterface >() );
+	Description >>= m_sDescription;
+	Source >>= m_sSource;
+	HelpFile >>= m_sHelpFile;
+	HelpContext >>= m_nHelpContext;
+	Number >>= m_nNumber;
+	if ( m_nNumber )
+	{
+		SbError n = StarBASIC::GetSfxFromVBError( m_nNumber );
+		if ( !n )
+			n = m_nNumber; // force orig number, probably should have a specific table of vb ( localized ) errors
+		pINST->Error( n, m_sDescription );
+	}
+}
+
+// XDefaultProperty	
+::rtl::OUString SAL_CALL 
+ErrObject::getDefaultPropertyName(  ) throw (uno::RuntimeException)
+{
+	static rtl::OUString sDfltPropName( RTL_CONSTASCII_USTRINGPARAM("Number") );
+	return sDfltPropName;
+}
+
+// SbxErrObject
+SbxErrObject::SbxErrObject( const String& rName, const Any& rUnoObj ): SbUnoObject( rName, rUnoObj )
+{
+	OSL_TRACE("SbxErrObject::SbxErrObject ctor");
+	rUnoObj >>= m_xErr;
+	if ( m_xErr.is() )
+		SetDfltProperty( uno::Reference< script::XDefaultProperty >( m_xErr, uno::UNO_QUERY_THROW )->getDefaultPropertyName() ) ;
+}
+
+SbxErrObject::~SbxErrObject()
+{
+	OSL_TRACE("SbxErrObject::~SbxErrObject dtor");
+}
+
+uno::Reference< vba::XErrObject > 
+SbxErrObject::getUnoErrObject()
+{
+	SbxVariable* pVar = getErrObject();
+	SbxErrObject* pGlobErr = static_cast< SbxErrObject* >(  pVar );
+	return pGlobErr->m_xErr;	
+}
+
+SbxVariableRef
+SbxErrObject::getErrObject()
+{
+	static SbxVariableRef pGlobErr = new SbxErrObject( String(  RTL_CONSTASCII_USTRINGPARAM("Err")), uno::makeAny( uno::Reference< vba::XErrObject >( new ErrObject() ) ) );
+	return pGlobErr;
+}
+
--- basic/source/runtime/runtime.cxx	2006-12-06 12:31:43.000000000 +0000
+++ basic/source/runtime/runtime.cxx	2006-12-07 17:10:53.000000000 +0000
@@ -64,6 +64,7 @@
 #include <com/sun/star/container/XEnumerationAccess.hpp>
 #endif
 #include "sbunoobj.hxx"
+#include "errobject.hxx"
 
 bool SbiRuntime::isVBAEnabled()
 {
@@ -287,6 +288,7 @@ SbiInstance::SbiInstance( StarBASIC* p )
 	nErl	 = 0;
 	bReschedule = TRUE;
 	bCompatibility = FALSE;
+	SbxErrObject::getUnoErrObject()->Clear();
 }
 
 SbiInstance::~SbiInstance()
@@ -799,7 +808,38 @@ BOOL SbiRuntime::Step()
 void SbiRuntime::Error( SbError n )
 {
 	if( n )
+	{
 		nError = n;
+		if ( isVBAEnabled() )
+		{
+			String aMsg = pInst->GetErrorMsg();
+			// If a message is defined use that ( in preference to
+			// the defined one for the error ) NB #TODO
+			// if there is an error defined it more than likely
+			// is not the one you want ( some are the same though )
+			// we really need a new vba compatible error list
+			if ( !aMsg.Len() )
+			{
+				StarBASIC::MakeErrorText( n, aMsg );	
+				aMsg =  StarBASIC::GetErrorText();
+				if ( !aMsg.Len() ) // no message for err no.
+					// need localized resource here
+					aMsg = String( RTL_CONSTASCII_USTRINGPARAM("Internal Object Error:") );
+			}
+			// no num? most likely then it *is* really a vba err
+			SbxErrObject::getUnoErrObject()->setNumber( ( StarBASIC::GetVBErrorCode( n ) == 0 ) ? n : StarBASIC::GetVBErrorCode( n ) );
+			SbxErrObject::getUnoErrObject()->setDescription( aMsg );
+
+			// prepend an error number to the message.
+			String aTmp = '\'';
+                        aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() );
+                        aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") );
+                        aTmp += aMsg;
+
+			pInst->aErrorMsg = aTmp;
+			nError = SbERR_BASIC_COMPAT;
+		}
+	}
 }
 
 void SbiRuntime::FatalError( SbError n )
--- basic/source/classes/sb.cxx	2006-12-06 12:07:07.000000000 +0000
+++ basic/source/classes/sb.cxx	2006-12-07 17:27:56.000000000 +0000
@@ -220,6 +220,7 @@ const SFX_VB_ErrorItem __FAR_DATA SFX_VB
 	{ 1004, SbERR_METHOD_FAILED },
 	{ 1005, SbERR_SETPROP_FAILED },
 	{ 1006, SbERR_GETPROP_FAILED },
+	{ 1007, SbERR_BASIC_COMPAT },
 	{ 0xFFFF, 0xFFFFFFFFL }		// End-Marke
 };
 
--- basic/source/classes/sb.src	2006-03-27 10:04:45.000000000 +0100
+++ basic/source/classes/sb.src	2006-12-07 14:59:07.000000000 +0000
@@ -572,6 +572,12 @@ Resource RID_BASIC_START
 	{
 		Text [ en-US ] = "An exception occurred $(ARG1)." ;
 	};
+	String ERRCODE_BASIC_COMPAT & ERRCODE_RES_MASK
+	{
+		Text [ de ] = "$(ARG1)." ;
+		Text [ en-US ] = "$(ARG1)." ;
+		Text [ x-comment ] = " ";
+	};
 };
  // Hinweis: IDS_SBERR_TERMINATED = IDS_SBERR_START+2000.
 String IDS_SBERR_TERMINATED
--- basic/inc/basic/sberrors.hxx	2005-09-07 22:02:23.000000000 +0100
+++ basic/inc/basic/sberrors.hxx	2006-12-07 15:00:01.000000000 +0000
@@ -285,6 +285,8 @@ typedef ULONG SbError;
 #define	ERRCODE_BASMGR_REMOVELIB			(LAST_SBX_ERROR_ID+101UL) | ERRCODE_AREA_SBX
 #define	ERRCODE_BASMGR_UNLOADLIB			(LAST_SBX_ERROR_ID+102UL) | ERRCODE_AREA_SBX
 
+#define	ERRCODE_BASIC_COMPAT				((LAST_SBX_ERROR_ID+103UL)| ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME)
+
 // Alte Codes auf neue mappen
 #define	SbERR_SYNTAX						ERRCODE_BASIC_SYNTAX
 #define	SbERR_NO_GOSUB						ERRCODE_BASIC_NO_GOSUB
@@ -409,6 +411,7 @@ typedef ULONG SbError;
 #define	SbERR_PROG_TOO_LARGE                ERRCODE_BASIC_PROG_TOO_LARGE
 #define	SbERR_NO_STRINGS_ARRAYS             ERRCODE_BASIC_NO_STRINGS_ARRAYS
 #define	SbERR_BASIC_EXCEPTION               ERRCODE_BASIC_EXCEPTION
+#define	SbERR_BASIC_COMPAT                  ERRCODE_BASIC_COMPAT
 // #define	SbERR_COMPILER_END					ERRCODE_BASIC_COMPILER_END
 
 
--- basic.orig/source/runtime/step0.cxx	2006-11-27 13:06:41.000000000 +0000
+++ basic/source/runtime/step0.cxx	2006-12-07 20:25:43.000000000 +0000
@@ -42,7 +42,7 @@
 #ifndef _FSYS_HXX //autogen
 #include <tools/fsys.hxx>
 #endif
-
+#include "errobject.hxx"
 #include "runtime.hxx"
 #include "sbintern.hxx"
 #include "iosys.hxx"
@@ -975,6 +976,7 @@ void SbiRuntime::StepSTDERROR()
 	pInst->nErr = 0L;
 	pInst->nErl = 0;
 	nError = 0L;
+	SbxErrObject::getUnoErrObject()->Clear();
 }
 
 void SbiRuntime::StepNOERROR()
@@ -1126,6 +1126,6 @@ void SbiRuntime::StepERROR()
 	SbxVariableRef refCode = PopVar();
 	USHORT n = refCode->GetUShort();
 	SbError error = StarBASIC::GetSfxFromVBError( n );
-	Error( error );
+	pInst->Error( error );
 }
 
