Click here to Skip to main content
15,885,885 members
Articles / Desktop Programming / WPF

Use WPF Controls in VSTO Solutions with Visual Basic 2008

Rate me:
Please Sign up or sign in to vote.
4.33/5 (4 votes)
9 Mar 2008CPOL2 min read 56.1K   717   19  
An explanation of how to add WPF controls to Visual Studio Tools for Office solutions, writing Visual Basic code
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <ProjectTypeGuids>{BAA0C2D2-18E2-41B9-852F-F413020CAA33};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <OutputType>Library</OutputType>
    <RootNamespace>WPFControlsExcelWorkbook</RootNamespace>
    <AssemblyName>WPFControlsExcelWorkbook</AssemblyName>
    <VSTO_HostDocumentName>WPFControlsExcelWorkbook.xlsx</VSTO_HostDocumentName>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <OfficeApplication>Excel</OfficeApplication>
    <BootstrapperEnabled>true</BootstrapperEnabled>
    <BootstrapperComponentsLocation>HomeSite</BootstrapperComponentsLocation>
    <OptionExplicit>On</OptionExplicit>
    <OptionCompare>Binary</OptionCompare>
    <OptionStrict>Off</OptionStrict>
    <OptionInfer>On</OptionInfer>
    <ProjectGuid>{8E705C4F-2B2C-40E8-B340-FE4274F41FAA}</ProjectGuid>
    <SolutionID>dbaaf2cc-46b8-4a06-a7c3-1af838952588</SolutionID>
    <ManifestCertificateThumbprint>84F31DCE5BC67456E41DD098DC6A777B2F3DACAC</ManifestCertificateThumbprint>
    <ManifestKeyFile>WPFControlsExcelWorkbook_TemporaryKey.pfx</ManifestKeyFile>
    <SignManifests>true</SignManifests>
  </PropertyGroup>
  <ItemGroup>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.VSTORuntime.3.0">
      <Visible>false</Visible>
      <ProductName>Microsoft Visual Studio Tools for Office Runtime 3.0</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
      <Visible>False</Visible>
      <ProductName>Windows Installer 3.1</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
  </ItemGroup>
  <PropertyGroup>
    <VSTO_EmbedTypeLibraryInAssembly>false</VSTO_EmbedTypeLibraryInAssembly>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DefineConstants>
    </DefineConstants>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <DebugType>full</DebugType>
    <DebugSymbols>true</DebugSymbols>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DocumentationFile>WPFControlsExcelWorkbook.xml</DocumentationFile>
    <RegisterForComInterop>false</RegisterForComInterop>
    <RemoveIntegerChecks>false</RemoveIntegerChecks>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DefineConstants>
    </DefineConstants>
    <DefineDebug>false</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DocumentationFile>WPFControlsExcelWorkbook.xml</DocumentationFile>
    <RegisterForComInterop>false</RegisterForComInterop>
    <RemoveIntegerChecks>false</RemoveIntegerChecks>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.AddIn, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Core">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Xml.Linq">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data.DataSetExtensions">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="Microsoft.Office.Tools.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
    <Reference Include="Microsoft.Office.Tools.Common.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
    <Reference Include="Microsoft.Office.Tools.Excel.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
    <Reference Include="Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="PresentationCore">
      <RequiredTargetFramework>3.0</RequiredTargetFramework>
    </Reference>
    <Reference Include="PresentationFramework">
      <RequiredTargetFramework>3.0</RequiredTargetFramework>
    </Reference>
    <Reference Include="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <Private>False</Private>
    </Reference>
    <Reference Include="Office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
      <Private>False</Private>
    </Reference>
    <Reference Include="Microsoft.Vbe.Interop, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
      <Private>False</Private>
    </Reference>
    <Reference Include="Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
      <Private>False</Private>
    </Reference>
    <Reference Include="UIAutomationProvider">
      <RequiredTargetFramework>3.0</RequiredTargetFramework>
    </Reference>
    <Reference Include="WindowsBase">
      <RequiredTargetFramework>3.0</RequiredTargetFramework>
    </Reference>
    <Reference Include="WindowsFormsIntegration">
      <RequiredTargetFramework>3.0</RequiredTargetFramework>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="System" />
    <Import Include="System.Collections.Generic" />
    <Import Include="System.Data" />
    <Import Include="System.Linq" />
    <Import Include="System.Text" />
    <Import Include="System.Windows.Forms" />
    <Import Include="System.Xml.Linq" />
    <Import Include="Microsoft.VisualStudio.Tools.Applications.Runtime" />
    <Import Include="Office = Microsoft.Office.Core" />
    <Import Include="Excel = Microsoft.Office.Interop.Excel" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Foglio1.Designer.vb">
      <DependentUpon>Foglio1.Designer.xml</DependentUpon>
    </Compile>
    <Compile Include="Foglio1.vb">
      <DependentUpon>WPFControlsExcelWorkbook.xlsx</DependentUpon>
    </Compile>
    <Compile Include="Foglio2.Designer.vb">
      <DependentUpon>Foglio2.Designer.xml</DependentUpon>
    </Compile>
    <Compile Include="Foglio2.vb">
      <DependentUpon>WPFControlsExcelWorkbook.xlsx</DependentUpon>
    </Compile>
    <Compile Include="Foglio3.Designer.vb">
      <DependentUpon>Foglio3.Designer.xml</DependentUpon>
    </Compile>
    <Compile Include="Foglio3.vb">
      <DependentUpon>WPFControlsExcelWorkbook.xlsx</DependentUpon>
    </Compile>
    <Compile Include="HostUserControl.Designer.vb">
      <DependentUpon>HostUserControl.vb</DependentUpon>
    </Compile>
    <Compile Include="HostUserControl.vb">
      <SubType>UserControl</SubType>
    </Compile>
    <Compile Include="My Project\AssemblyInfo.vb" />
    <EmbeddedResource Include="Foglio1.resx">
      <DependentUpon>Foglio1.vb</DependentUpon>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <EmbeddedResource Include="HostUserControl.resx">
      <DependentUpon>HostUserControl.vb</DependentUpon>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <EmbeddedResource Include="My Project\Resources.resx">
      <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.vb</LastGenOutput>
      <CustomToolNamespace>My.Resources</CustomToolNamespace>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <Compile Include="My Project\Resources.Designer.vb">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <None Include="My Project\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.vb</LastGenOutput>
    </None>
    <None Include="WPFControlsExcelWorkbook.xlsx" />
    <Compile Include="My Project\Settings.Designer.vb">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
    <Compile Include="ThisWorkbook.Designer.vb">
      <DependentUpon>ThisWorkbook.Designer.xml</DependentUpon>
    </Compile>
    <Compile Include="ThisWorkbook.vb">
      <DependentUpon>WPFControlsExcelWorkbook.xlsx</DependentUpon>
    </Compile>
    <Compile Include="WPFControlsExcelWorkbook.Designer.vb">
      <DependentUpon>WPFControlsExcelWorkbook.Designer.xml</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <None Include="ThisWorkbook.Designer.xml">
      <DependentUpon>ThisWorkbook.vb</DependentUpon>
    </None>
  </ItemGroup>
  <ItemGroup>
    <None Include="Foglio1.Designer.xml">
      <DependentUpon>Foglio1.vb</DependentUpon>
    </None>
  </ItemGroup>
  <ItemGroup>
    <None Include="Foglio2.Designer.xml">
      <DependentUpon>Foglio2.vb</DependentUpon>
    </None>
  </ItemGroup>
  <ItemGroup>
    <None Include="Foglio3.Designer.xml">
      <DependentUpon>Foglio3.vb</DependentUpon>
    </None>
    <None Include="WPFControlsExcelWorkbook_TemporaryKey.pfx" />
  </ItemGroup>
  <ItemGroup>
    <Service Include="{94E38DFF-614B-4CBD-B67C-F211BB35CE8B}" />
  </ItemGroup>
  <ItemGroup>
    <None Include="WPFControlsExcelWorkbook.Designer.xml">
      <DependentUpon>WPFControlsExcelWorkbook.xlsx</DependentUpon>
    </None>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.Office2007.targets" />
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
        <ProjectProperties HostName="WPFControlsExcelWorkbook.xlsx" HostPackage="{B284B16A-C42C-4438-BDCD-B72F4AC43CFB}" OfficeVersion="12.0" VstxVersion="3.0" ApplicationType="XLS" Language="VB" TemplatesPath="VSTOTemplates" DebugInfoExeName="E:\Program Files\Microsoft Office\Office12\Excel.exe" DebugInfoCommandLine="&quot;[$OUTPUT]WPFControlsExcelWorkbook.xlsx&quot;" />
        <Host Name="Excel Document" Path=".\WPFControlsExcelWorkbook.xlsx">
          <HostControls Blueprint="WPFControlsExcelWorkbook.Designer.xml" GeneratedCode="WPFControlsExcelWorkbook.Designer.vb" />
          <HostItem Name="Foglio1" Code="Foglio1.vb" CanonicalName="Foglio1" DisplayName="Foglio1" Blueprint="Foglio1.Designer.xml" GeneratedCode="Foglio1.Designer.vb" />
          <HostItem Name="Foglio2" Code="Foglio2.vb" CanonicalName="Foglio2" DisplayName="Foglio2" Blueprint="Foglio2.Designer.xml" GeneratedCode="Foglio2.Designer.vb" />
          <HostItem Name="Foglio3" Code="Foglio3.vb" CanonicalName="Foglio3" DisplayName="Foglio3" Blueprint="Foglio3.Designer.xml" GeneratedCode="Foglio3.Designer.vb" />
          <HostItem Name="ThisWorkbook" Code="ThisWorkbook.vb" CanonicalName="ThisWorkbook" Blueprint="ThisWorkbook.Designer.xml" GeneratedCode="ThisWorkbook.Designer.vb" />
        </Host>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
  <!--
    To modify your build process, add your task inside one of the targets below and uncomment it.
    Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Other
Italy Italy
I'm a Microsoft Visual Basic MVP. I'm an Italian .NET developer and I write articles and books about Visual Basic, Visual Studio LightSwitch, and the .NET technologies.

Check out my blog at: http://community.visual-basic.it/AlessandroEnglish

Comments and Discussions