Export (0) Print
Expand All

"Visual Studio Tools for Office" Frequently Asked Questions

Office 2003
 

Lori Turner
Marc LaPierre
Microsoft Corporation

April 2003

Applies to:
   Microsoft® "Visual Studio Tools for Office" Beta
   Microsoft Office System
   Microsoft Visual Studio® .NET 2003

Summary: Contains frequently asked questions about installing and using "Visual Studio Tools for Office" Beta and provides solutions to common problems. (12 printed pages)

Contents

Setup
Primary Interop Assemblies (PIAs)
Samples
Usage and Development

Setup

Q1. When I run Microsoft "Visual Studio for Office" Setup, I receive the message "Your computer does not have all the prerequisites. Refer to the installation page for details." What are possible causes of this error?

Q2. How do I install the Office Primary Interop Assemblies (PIAs)?

Q3. "Visual Studio Tools for Office" Beta Setup runs without error, but the documentation does not appear in MSDN.

Q4. When I run Setup, I receive the message "This beta version of Visual Studio .NET Tools for Office has expired, and cannot be installed. For information on the latest version, see the official Web site at http://msdn.microsoft.com/vstudio/office." What can I do to install "Visual Studio Tools for Office"?

Q5. When I run Setup for "Visual Studio Tools for Office," it appears to hang with a status message of "Removing Backup Files."

Primary Interop Assemblies (PIAs)

Q6. I cannot programmatically cancel certain Microsoft Office Excel 2003 events by setting the Cancel parameter to True when using the Excel PIA.

Q7. When my regional settings are set to something different than the installed language in Excel, the managed code in my Excel project fails.

Q8. With C#, some Microsoft Office Excel and Microsoft Office Word properties do not appear in IntelliSense. Why?

Samples

Q9. How do I set up Microsoft SQL Server 2000 Desktop Engine (MSDE)?

Q10. How do I remove the sample databases with MSDE?

Q11. I cannot set the project start settings for the C# samples included with "Visual Studio Tools for Office." How can I fix this?

Q12. When the Estimates sample loads, it displays a warning, "Privacy warning: This document contains macros, ActiveX controls, XML expansion pack information, or Web components. These may include personal information that cannot be removed by the 'Remove personal information from file properties on save' option on the Security tab of the Options dialog box on the Tools menu." I thought managed code bypasses Office Visual Basic for Applications (VBA) macro security, so why does this warning appear?

Usage and Development

Q13. In what scenarios does managed code run?

Q14. My document (or workbook) is on a network share but my managed code does not run when I open it. How can I fix this?

Q15. Can I create Office projects using an HTTP location?

Q16. When I stop debugging my project, my Word (or Excel) instance is terminated. Is this the expected behavior, and if so, how can I prevent this?

Q17. I created a new project and ran it, and it worked as expected. However, after modifying the project properties, the assembly fails to load. What could be the cause?

Q18. When I debug my project for a Word template solution, the template opens in Word instead of a copy of the template. How can I correct this?

Q19. I have created an Excel project based on a workbook saved in the "XML Spreadsheet" format. When I run the workbook project from Visual Studio .NET, the ThisWorkbook_Open event does not fire.

Q20. Pressing the SHIFT key does not disable managed code extensions for my workbook. How can I disable the managed code so that I may edit my workbook without managed code running?

Q21. Can I "attach" a Word template with managed code to a new or existing document?

Q22. I have a workbook containing ActiveX controls with managed code extensions. This workbook also contains VBA code. When I open the workbook with macro security set to "High", the code in the workbook's Open event runs but the code does not handle events for the ActiveX controls on the workbook. How can I resolve this?

Q23. Can a Word document (or Excel workbook) have more than one assembly assigned to it?

Q24. Can I use my documents created with "Visual Studio Tools for Office" with a managed Smart Document solution?

Setup

Q1.  When I run Microsoft® "Visual Studio Tools for Office" Setup, I receive the message "Your computer does not have all the prerequisites. Refer to the installation page for details." What are possible causes of this error?

A1.  All of the following are required for "Visual Studio Tools for Office" Beta Setup:

  • Microsoft Visual Studio® .NET 2003 (build 3077 and above)
  • Microsoft .NET Framework 1.1 (build 4322.586 and above)
  • Microsoft Office Professional Edition 2003 (Beta)
  • Administrative privileges on the target computer.
  • The following Primary Interop Assemblies (PIAs) must be installed prior to running "Visual Studio Tools for Office" Setup. These PIAs are included with Office Setup and must be installed with the option "Run From My Computer"; you will receive the prerequisite error if you choose "Installed on First Use" for any one of the following PIAs:

Q2.  How do I install the Office Primary Interop Assemblies (PIAs)?

A2.  The PIAs require the Microsoft .NET Framework 1.1 which is included with Visual Studio .NET 2003 Setup. It is recommended that you install Visual Studio .NET before you install Microsoft Office 2003. With the .NET Framework 1.1 already installed, a complete installation of Office will install all of the PIAs required for "Visual Studio Tools for Office."

The Office PIAs are included with Office Setup and may be added in Setup Maintenance mode if needed.

To install the PIAs required by "Visual Studio Tools for Office"

  1. Open Control Panel and double-click Add or Remove Programs.
  2. Select Microsoft Office 2003 in the list of currently installed programs and click Change. Office Setup starts in Maintenance Mode.
  3. Select the Add or Remove Features option and click Next.
  4. Check Choose Advanced Customization of Applications and click Next.
  5. Set all of the PIAs to Run From My Computer. Table 1 shows where you can find all of the PIAs in the Office features tree.

    Table 1. Location of Office primary interop assemblies

    Primary interop assembly Location
    Microsoft Excel 11 PIA Microsoft Office > Microsoft Excel for Windows > .NET Programmability Support
    Microsoft Word 11 PIA Microsoft Office > Microsoft Word for Windows > .NET Programmability Support
    Microsoft Forms 2.0 PIA Microsoft Office > Office Tools > Forms 2.0 .NET Programmability Support
    Microsoft Graph 11 PIA Microsoft Office > Office Tools > Microsoft Graph > .NET Programmability Support

Q3.  "Visual Studio Tools for Office" Beta Setup runs without error, but the documentation does not appear in MSDN.

A3.  "Visual Studio Tools for Office" Beta Setup will install the documentation only for February 2003 MSDN. MSDN Subscribers should note the following:

  • If you install April 2003 MSDN and then run "Visual Studio Tools for Office" Beta Setup, the documentation will not be installed.
  • If you have successfully installed the "Visual Studio Tools for Office" Beta documentation with the February 2003 MSDN, the "Visual Studio Tools for Office" Beta documentation will be removed if you later install the April 2003 MSDN documentation.

This issue is currently under investigation.

Q4.  When I run Setup, I receive the message "This beta version of Visual Studio .NET Tools for Office has expired, and cannot be installed. For information on the latest version, see the official Web site at http://msdn.microsoft.com/vstudio/office." What can I do to install "Visual Studio Tools for Office"?

A4.  The "Visual Studio Tools for Office" Beta cannot be installed after 11/30/2003. If you receive this error prior to 11/30/2003, please contact your Product Support Services (PSS) beta representative for assistance.

Q5.  When I run Setup for "Visual Studio Tools for Office," it appears to hang with a status message of "Removing Backup Files."

A5.  The message may be misleading with respect to what Setup is actually doing at that time. At the end of the setup process, "Visual Studio Tools for Office" Setup integrates its help and samples with MSDN. This process can take approximately 5-10 minutes; you should allow time for Setup to complete Microsoft Developer Network (MSDN) integration.

Primary Interop Assemblies (PIAs)

Q6.  I cannot programmatically cancel certain Microsoft Office Excel 2003 events by setting the Cancel parameter to True when using the Excel PIA.

A6.  This is a known issue that is currently under investigation.

Q7.  When my regional settings are set to something different than the installed language in Excel, the managed code in my Excel project fails.

A7.  This is a known issue that is currently under investigation. To resolve this problem, you can change the culture information for the thread to match the locale identifier (LCID) for the installed language in Excel.

For Visual Basic .NET:

    ' Visual Basic
    'Get the CultureInfo that corresponds to the LCID.
    Dim nID As Integer = ThisApplication.LanguageSettings.LanguageID( _
        Microsoft.Office.Core.MsoAppLanguageID.msoLanguageIDInstall)
    System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(nID)

    Try
        ThisWorkbook.Worksheets(1).Range("A1").Value = "Hi"
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

For C#:

    // C#
    int nID = ThisApplication.LanguageSettings.get_LanguageID( 
        Microsoft.Office.Core.MsoAppLanguageID.msoLanguageIDInstall);
    System.Threading.Thread.CurrentThread.CurrentCulture = 
        new System.Globalization.CultureInfo(nID);
    try
    {
        Excel.Worksheet s = (Excel.Worksheet)(ThisWorkbook.Worksheets[1]);
        s.get_Range("A1", Type.Missing).set_Value(
            Excel.XlRangeValueDataType.xlRangeValueDefault, "Hello");
    }           
    catch (Exception ex)
    {
        System.Windows.Forms.MessageBox.Show(ex.Message);
    }

Q8.  With C#, some Microsoft Office Excel and Microsoft Office Word properties do not appear in IntelliSense. Why?

A8.  In C#, properties are not expected to have any parameters; however some Excel and Word properties do have parameters. These properties do appear in IntelliSense, but they appear prefixed with either get_ or set_. Two examples of these properties are the Excel Range and Value properties:

    // C#
    Excel.Worksheet
    s = (Excel.Worksheet)(ThisWorkbook.Worksheets[1]);
    Excel.Range r = s.get_Range("A1", Type.Missing);
    r.set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, "Hello!");

Samples

Q9.  How do I set up Microsoft SQL Server 2000 Desktop Engine (MSDE)?

A9.  To use the "Visual Studio Tools for Office" samples that use a database, you must have SQL Server 2000 or MSDE installed. MSDE is included with your Office 2003 Beta CD.

To install MSDE from your Office 2003 Beta CD:

  1. Run Sql2ksp3.exe in the MSDE folder of your Office 2003 Beta CD to extract the Setup files.
  2. Run Setup.exe from the folder where you extracted the files.
  3. When you run Setup.exe, you are required to specify a parameter for the database administrator's password. To specify a password, use a command line such as:
    C:\Sql2ksp3\Setup.exe SAPWD=<Enter Your Password Here>
    
    

    In the command line, replace <Enter Your Password Here> with a strong password. For your increased security, you should also consider turning off SQL Authentication/Mixed Mode and use only Windows Authentication.

    For more details on additional parameters that you can use for MSDE Setup, refer to the "Install Desktop Engine SP3" section of Sp3readme.htm, which is located in the folder where you extracted the MSDE Setup files.

  4. Restart the computer after installing MSDE to configure and start the SQL Server services.

    You may also install MSDE from the Microsoft Download Center.

Q10.  How do I remove the sample databases with MSDE?

A10.  To drop a sample database, issue the following command at a command prompt:

     oSQL.exe –E /Q "DROP DATABASE [EstimatesSample];"

To find information on the parameters for oSQL.exe, use:

     oSQL.exe /?

Q11.  I cannot set the project start settings for the C# samples included with "Visual Studio Tools for Office." How can I fix this?

A11.  To run the C# samples from Visual Studio .NET, you must first set the Start Action and Start Options debug settings.

  1. With the C# sample solution open in Visual Studio .NET, click [Project Name] Properties on the Project menu.
  2. In the Configuration drop-down list, choose All Configurations.
  3. Select Debugging under Configuration Properties.
  4. Change the Debug Mode to Program and click Apply.
    Note   You must click Apply to proceed.
  5. You may now provide the command line for Winword.exe (or Excel.exe) and the command line arguments.

For more details, see the "Visual Studio Tools for Office" help topic, "A project with an Output Type of Class Library cannot be started directly".

Q12.  When the Estimates sample loads, it displays a warning, "Privacy warning: This document contains macros, ActiveX controls, XML expansion pack information, or Web components. These may include personal information that cannot be removed by the 'Remove personal information from file properties on save' option on the Security tab of the Options dialog box on the Tools menu." I thought managed code bypasses Office Visual Basic for Applications (VBA) macro security, so why does this warning appear?

A12.  Solutions with managed code extensions do indeed bypass Excel and Word macro security settings.

In the workbook's Open event, the workbook is saved to create a copy of the workbook "template," Estimates.xls. Estimates.xls was originally saved with the "Remove personal information from file properties on save" setting checked; therefore, when the SaveAs method executes, you will see this warning because the workbook contains ActiveX controls.

To avoid this warning:

  1. Open Estimates.xls in Excel.
  2. On the Tools menu, choose Options and select the Security tab. Clear the check box for the setting, "Remove personal information from file properties on save," and click OK.
  3. Save the workbook and try the sample again.

    If you wish to leave the "Remove personal information file properties on save" setting selected, you might consider moving the save routine to the workbook's BeforeSave event. With this approach, users would only see the warning when they choose to save. For more details, see the "Visual Studio Tools for Office" help topic, "How to: Add Template Behavior to an Excel Workbook".

Usage and Development

Q13.  In what scenarios does managed code run?

A13.  Table 2 shows the different scenarios for opening Excel and Word documents. The scenarios in this table all assume that the assembly for the document/workbook has been trusted.

Table 2. Managed code scenarios

If the document/workbook is Then managed code
Opened using a file path (local or shared) in the Office application Will run.
Opened using an HTTP path in the Office application (where the http:// location is trusted at the machine level) Will not run.

This scenario is currently being investigated.

Opened using a file path (local or shared) in Internet Explorer Will not run.

This scenario is currently being investigated.

Opened using an HTTP path in Internet Explorer Will not run.

This scenario is currently being investigated.

Opened in Microsoft SharePoint™ Will not run.

This scenario is currently being investigated.

Opened as an embedded object in an OLE document container Word: Will not run.

No events are generated when an embedded/linked Word document is activated or opened; events are not raised for either managed code or VBA.

Excel: Will run.

Opened from an attachment in e-mail Will not run.

By default, an assembly does not execute if the document with managed code extensions is opened directly from an e-mail message because e-mail attachments are in the Internet Zone (which does not have full trust). However, if the mail recipient saves the document to their local hard disk and opens the saved copy of the document, the managed code will run provided that the document contains a full path to a fully trusted assembly.

Opened by clicking a hyperlink in another document/workbook Word: Will not run.
Example: You have a Word document (Doc1) containing a hyperlink to another Word document (Doc2). Doc2 contains managed code. When you click the hyperlink in Doc1, Doc2 opens, but managed code does not run. This scenario is currently being investigated.

Excel: Will run.
Example: You have an Excel workbook (Book1) containing a hyperlink to another Excel workbook (Book2). Book2 contains managed code. When you click the hyperlink in Book1, Book2 opens and managed code will run.

For more details, refer to the following help topics in the "Visual Studio Tools for Office" documentation:

  • Secure Deployment
  • Specific Security Considerations
  • Security Requirements to Run Office Solutions

Q14.  My document (or workbook) is on a network share but my managed code does not run when I open it. How can I fix this?

A14.  Documents on a network share require full trust at the machine level. If you originally created your project on a network share, full trust is given to the assembly but not the document. Without full trust for the document, you will receive the message "The current .NET security policy does not permit \\server\share\..\document to load custom macros." when you run your project. To resolve this problem, grant full trust at the machine level for the document as described in the "Visual Studio Tools for Office" help topic, "How to: Grant Permissions to Folders and Assemblies".

Q15.  Can I create Office projects using an HTTP location?

A15.  No, the Microsoft Office Project Wizard will not allow you to provide an HTTP path for the project location. However, you can map a drive to your Web server or share a folder on your Web server and then use the mapped drive or network share for the Office project location.

You should also note that changing the project's "Assembly Link Location" setting to an HTTP location automatically sets the project's "Copy Assembly" property to False. For security purposes, assemblies cannot be copied to an HTTP location during the build process, but you can copy your assemblies to the desired location once the build process is complete.

Q16.  When I stop debugging my project, my Word (or Excel) instance is terminated. Is this the expected behavior, and if so, how can I prevent this?

A16.  When you use the "Stop Debugging" command on the Debug menu in Visual Studio .NET, it terminates the application you used to start the debug session; this is the expected behavior. If you want to end your debug session and leave your Word document (or Excel workbook) open, you should instead choose "Detach All" on the Debug menu.

Q17.  I created a new project and ran it, and it worked as expected. However, after modifying the project properties, the assembly fails to load. What could be the cause?

A17.  If you change the Assembly Link Location property or the name of the assembly and then rebuild your project, the _AssemblyLocation0 and _AssemblyName0 document properties will be updated during the build process. However, the build process will not update the security policy to reflect your change; security policies are updated only during the initial project creation. So, if you change either the Assembly Link Location or the assembly name, you will need to update your Microsoft .NET security settings to reflect the new file name or location.

You should also make note of the project's Copy Assembly property. If Copy Assembly is disabled or set to False, the build process will not copy the assembly to the link location. When you change the project's Assembly Link Location to a network path, the Copy Assembly property is automatically set to False. Likewise, when you change the Assembly Link Location to an HTTP path, the Copy Assembly property is disabled.

Q18.  When I debug my project for a Word template solution, the template opens in Word instead of a copy of the template. How can I correct this?

A18. To open a copy of your template, you should precede the template with the /Z switch in the Command Line Arguments setting of the project's Debug configuration. For example:

     /Z"..\WORDPROJECT1.DOT"

You should note that there is no space between /Z and the template.

Q19.  I have created an Excel project based on a workbook saved in the "XML Spreadsheet" format. When I run the workbook project from Visual Studio .NET, the ThisWorkbook_Open event does not fire.

A19. If your workbook is saved in a non-native file format, then the workbook's Open event will not fire if the workbook is opened in one of the following ways:

  • Started from Visual Studio .NET.
  • From a command prompt (that is, Run from the Windows Start menu).
  • By double-clicking the workbook file in Windows Explorer.

This is a known issue. It affects non-native formats like XML Spreadsheet and Excel 5.0/95. Note that while the Open event does not fire, other Workbook events like Close will fire.

Q20.  Pressing the SHIFT key does not disable managed code extensions for my workbook. How can I disable the managed code so that I may edit my workbook without managed code running?

A20. This issue is currently being investigated. There are other methods for disabling managed code; for details, see the "Visual Studio Tools for Office" help topic "How to: Bypass the Assembly When Opening an Office Solution".

Q21.  Can I "attach" a Word template with managed code to a new or existing document?

A21.  The ability to attach a template (from Templates and Addins on the Word Tools menu) is not implemented.

Q22.  I have a workbook containing ActiveX controls with managed code extensions. This workbook also contains VBA code. When I open the workbook with macro security set to "High", the code in the workbook's Open event runs but the code does not handle events for the ActiveX controls on the workbook. How can I resolve this?

A22.  When macro security is set to high, the ActiveX controls will always be in design-mode if the workbook contains VBA code. Since you cannot exit design-mode in this scenario, your managed code cannot run. To resolve this problem, you can either remove the VBA code in the workbook or digitally sign the workbook's VBA project.

Q23.  Can a Word document (or Excel workbook) have more than one assembly assigned to it?

A23.  You can have only one assembly assigned to a document or workbook. However, that one assembly can reference other assemblies that are trusted and reside in the same directory (or in the global assembly cache).

Q24.  Can I use my documents created with "Visual Studio Tools for Office" with a managed Smart Document solution?

A24.  Smart Document solutions can coexist with "Visual Studio Tools for Office" managed extensions in certain cases:

  • You can attach an XML Schema for a managed Smart Document solution to a document that uses managed code extensions. But, in this scenario, the assemblies are loaded into separate AppDomains that are completely isolated; so, the assemblies cannot communicate with one another.
  • You cannot use assemblies created with "Visual Studio Tools for Office" in a Smart Document manifest.
Show:
© 2014 Microsoft