Important This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:
256986 (http://support.microsoft.com/kb/256986/) Description of the Microsoft Windows Registry
On This Page
SYMPTOMS
When you run a command to close a Microsoft Office Excel 2007 or Microsoft Office Excel 2003 document from the SmartDocument_Initialize event of a Smart Document solution, you may receive the following error message:
Microsoft Office Excel 2007
Microsoft Office Excel has stopped working.
Microsoft Office Excel 2003
Microsoft Office Excel has encountered a problem and needs to close. We are sorry for the inconvenience.
When you run a command to close a Microsoft Office Word 2007 document or a Microsoft Office Word 2003 document from the SmartDocument_Initialize event of a Smart Document solution, you may receive the following error message:
Microsoft Office Word 2007
Microsoft Office Word has stopped working.
Microsoft Office Word 2003
Microsoft Office Word has encountered a problem and needs to close. We are sorry for the inconvenience.
Warning If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.
Note The following steps use information and files that are installed with the Microsoft Office 2003 Smart Document software development kit (SDK). For additional information about how to download and how to install the Office 2003 Smart Document SDK, visit the following Microsoft Web site:
To create the Smart Document solution, follow these steps:
1.
Start Microsoft Visual Basic 6.0.
2.
On the
File
menu, click
New Project.
3.
In the
New Project
dialog box, select
ActiveX DLL,
and then click
OK.
4.
Type SDCloseonInit for the Project Name.
5.
In the Class Module window, add the following code:
Implements ISmartDocument
Dim spath As String
'Namespace constant
Const cNAMESPACE As String = "SDCloseonInit"
'Element constants
Const cTEXTBOX As String = cNAMESPACE & "#textbox"
Const cBUTTON As String = cNAMESPACE & "#commandbutton"
Const cTypes As Integer = 2
Private Sub ISmartDocument_SmartDocInitialize(ByVal ApplicationName As String, ByVal Document As Object,
ByVal SolutionPath As String, ByVal SolutionRegKeyRoot As String)
spath = SolutionPath
If ApplicationName = "Word.Application.11" Then
Dim solutionDoc As Word.Document
Set solutionDoc = Document
solutionDoc.Close False 'This line causes the error.
Else
Dim solutionBook As Workbook
Set solutionBook = Document
solutionBook.Close False 'This line causes the error.
End If
On Error GoTo SDIERR
Exit Sub
SDIERR:
MsgBox "Solution error:" & Err.Description
Err.Clear
Resume Next
End Sub
Private Property Get ISmartDocument_SmartDocXmlTypeCount() As Long
ISmartDocument_SmartDocXmlTypeCount = cTypes
End Property
Private Property Get ISmartDocument_SmartDocXmlTypeName( _
ByVal XMLTypeID As Long) As String
Select Case XMLTypeID
Case 1
ISmartDocument_SmartDocXmlTypeName = cTEXTBOX
Case 2
ISmartDocument_SmartDocXmlTypeName = cBUTTON
Case Else
End Select
End Property
Private Property Get ISmartDocument_SmartDocXmlTypeCaption( _
ByVal XMLTypeID As Long, ByVal LocaleID As Long) As String
Select Case XMLTypeID
Case 1
ISmartDocument_SmartDocXmlTypeCaption = "Textbox"
Case 2
ISmartDocument_SmartDocXmlTypeCaption = "Click"
Case Else
End Select
End Property
Private Property Get ISmartDocument_ControlCount( _
ByVal XMLTypeName As String) As Long
Select Case XMLTypeName
Case cTEXTBOX
ISmartDocument_ControlCount = 1
Case cBUTTON
ISmartDocument_ControlCount = 1
Case Else
End Select
End Property
'The ControlID for the first control that you add is 1.
'For additional information about how to specify the ControlID, see the ControlID reference
'topic in the References section of this SDK.
Private Property Get ISmartDocument_ControlID( _
ByVal XMLTypeName As String, _
ByVal ControlIndex As Long) As Long
Select Case XMLTypeName
Case cTEXTBOX
ISmartDocument_ControlID = ControlIndex
Case cBUTTON
ISmartDocument_ControlID = ControlIndex + 100
Case Else
End Select
End Property
Private Property Get ISmartDocument_ControlNameFromID( _
ByVal ControlID As Long) As String
ISmartDocument_ControlNameFromID = cNAMESPACE & ControlID
End Property
Private Property Get ISmartDocument_ControlCaptionFromID( _
ByVal ControlID As Long, ByVal ApplicationName As String, _
ByVal LocaleID As Long, ByVal Text As String, _
ByVal Xml As String, ByVal Target As Object) As String
Select Case ControlID
Case 1
ISmartDocument_ControlCaptionFromID = _
"Enter your name:"
Case 101
ISmartDocument_ControlCaptionFromID = _
"Test button"
Case Else
End Select
End Property
Private Property Get ISmartDocument_ControlTypeFromID( _
ByVal ControlID As Long, _
ByVal ApplicationName As String, _
ByVal LocaleID As Long) As SmartTagLib.C_TYPE
Select Case ControlID
Case 1
ISmartDocument_ControlTypeFromID = C_TYPE_TEXTBOX
Case 101
ISmartDocument_ControlTypeFromID = C_TYPE_BUTTON
Case Else
End Select
End Property
Private Sub ISmartDocument_PopulateActiveXProps(ByVal ControlID As Long, ByVal ApplicationName As String,
ByVal LocaleID As Long, ByVal Text As String, ByVal Xml As String, ByVal Target As Object,
ByVal Props As SmartTagLib.ISmartDocProperties, ByVal ActiveXPropBag As SmartTagLib.ISmartDocProperties)
End Sub
Private Sub ISmartDocument_PopulateCheckbox(ByVal ControlID As Long, ByVal ApplicationName As String,
ByVal LocaleID As Long, ByVal Text As String, ByVal Xml As String, ByVal Target As Object,
ByVal Props As SmartTagLib.ISmartDocProperties, Checked As Boolean)
End Sub
Private Sub ISmartDocument_PopulateDocumentFragment(ByVal ControlID As Long, ByVal ApplicationName As String,
ByVal LocaleID As Long, ByVal Text As String, ByVal Xml As String, ByVal Target As Object,
ByVal Props As SmartTagLib.ISmartDocProperties, DocumentFragment As String)
End Sub
Private Sub ISmartDocument_PopulateHelpContent(ByVal ControlID As Long, ByVal ApplicationName As String,
ByVal LocaleID As Long, ByVal Text As String, ByVal Xml As String, ByVal Target As Object,
ByVal Props As SmartTagLib.ISmartDocProperties, Content As String)
End Sub
Private Sub ISmartDocument_PopulateImage(ByVal ControlID As Long, ByVal ApplicationName As String,
ByVal LocaleID As Long, ByVal Text As String, ByVal Xml As String, ByVal Target As Object,
ByVal Props As SmartTagLib.ISmartDocProperties, ImageSrc As String)
End Sub
Private Sub ISmartDocument_PopulateListOrComboContent(ByVal ControlID As Long,
ByVal ApplicationName As String, ByVal LocaleID As Long, ByVal Text As String,
ByVal Xml As String, ByVal Target As Object, ByVal Props As SmartTagLib.ISmartDocProperties,
List() As String, count As Long, InitialSelected As Long)
End Sub
Private Sub ISmartDocument_PopulateOther(ByVal ControlID As Long, ByVal ApplicationName As String,
ByVal LocaleID As Long, ByVal Text As String, ByVal Xml As String, ByVal Target As Object,
ByVal Props As SmartTagLib.ISmartDocProperties)
End Sub
Private Sub ISmartDocument_PopulateRadioGroup(ByVal ControlID As Long, ByVal ApplicationName As String,
ByVal LocaleID As Long, ByVal Text As String, ByVal Xml As String, ByVal Target As Object,
ByVal Props As SmartTagLib.ISmartDocProperties, List() As String, count As Long, InitialSelected As Long)
End Sub
Private Sub ISmartDocument_PopulateTextboxContent( _
ByVal ControlID As Long, ByVal ApplicationName As String, _
ByVal LocaleID As Long, ByVal Text As String, _
ByVal Xml As String, ByVal Target As Object, _
ByVal Props As SmartTagLib.ISmartDocProperties, Value As String)
End Sub
Private Sub ISmartDocument_ImageClick(ByVal ControlID As Long, ByVal ApplicationName As String,
ByVal Target As Object, ByVal Text As String, ByVal Xml As String, ByVal LocaleID As Long,
ByVal XCoordinate As Long, ByVal YCoordinate As Long)
End Sub
Private Sub ISmartDocument_InvokeControl(ByVal ControlID As Long, ByVal ApplicationName As String,
ByVal Target As Object, ByVal Text As String, ByVal Xml As String, ByVal LocaleID As Long)
End Sub
Private Sub ISmartDocument_OnCheckboxChange(ByVal ControlID As Long, ByVal Target As Object,
ByVal Checked As Boolean)
End Sub
Private Sub ISmartDocument_OnListOrComboSelectChange(ByVal ControlID As Long, ByVal Target As Object,
ByVal Selected As Long, ByVal Value As String)
End Sub
Private Sub ISmartDocument_OnRadioGroupSelectChange(ByVal ControlID As Long, ByVal Target As Object,
ByVal Selected As Long, ByVal Value As String)
End Sub
Private Sub ISmartDocument_OnTextboxContentChange( _
ByVal ControlID As Long, ByVal Target As Object, _
ByVal Value As String)
End Sub
Private Sub ISmartDocument_OnPaneUpdateComplete(ByVal Document As Object)
End Sub
6.
Office 2007 On the
Project
menu, add a reference to the
following libraries, and then click OK:
•
Microsoft Excel 12.0 Object Library
•
Microsoft Word 12.0 Object Library
•
Microsoft Smart Tags 2.0 Type Library
.
Office 2003 On the
Project
menu, add a reference to the
following libraries, and then click OK:
•
Microsoft Excel 11.0 Object Library
•
Microsoft Word 11.0 Object Library
•
Microsoft Smart Tags 2.0 Type Library
Click
OK.
7.
On the
File
menu, click
Make SDCloseonInit.dll
to build the Smart Document solution.
To create the Manifest file, follow these steps:
1.
Start Notepad, and then paste the following code in the Notepad document:
Save the file as
SDCloseonInit.xsd.
Close the SDCloseonInit.xsd file.
To create the Excel 2003 file and to test the Smart Document, follow these steps:
1.
Locate the DisableManifestSecurityCheck.reg file that is installed with the Office 2003 Smart Document SDK. Double-click DisableManifestSecurityCheck.reg to add the registry key that disables the manifest security check.
2.
Start Excel.
3.
In Excel 2007, click the Developer tab, and then click Expansion Packs. In Excel 2003
click
XML on the
Data
menu,
and then
click XML Expansion Packs.
4.
In the
XML Expansion Packs
dialog box, click Add.
5.
Move to the location of the SDCloseonInitManifest.xml file that you previously created. Select the SDCloseonInitManifest.xml file, and then click
Open.
Click
No if you receive the following message:
XML expansion pack security has been disabled. This makes development of the solution easier but allows unsafe XML expansion pack components to run. Would you like to re-enable XML expansion pack security?
6.
In the Available XML expansion packs
list, select SDCloseonInit - VB6, and then click Attach. Click OK to close the XML Expansion Packs dialog box.
You may receive the Excel 2003 error message that is mentioned in the "Symptoms" section.
Need More Help? Contact a Support professional by E-mail, Online or Phone.
Customer Service For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
Newsgroups Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.