Click here to Skip to main content
15,896,557 members
Articles / Productivity Apps and Services / Microsoft Office

Hiding and Storing/caching of Application Specific data in MS Word 2003 documents

Rate me:
Please Sign up or sign in to vote.
3.54/5 (8 votes)
9 Oct 2008CPOL8 min read 29.1K   512   18  
Proof of concept on how the application specific (small/large amount of) data can be stored in ms word document as well as how it can be made hidden from end user’s eye.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- This section defines project level properties.
         
         Configuration : Specifies a default value for debug.
         Platform : Specifies what CPU the output of this project can run on.
         OutputType : Must be "Library" for VSTO.
         NoStandardLibraries : Set to "false" for VSTO.
         RootNamespace : In C#, this specifies the namespace given to new files. In VB, all objects are wrapped in
                         this namespace at runtime.
         AssemblyName : Name of the output assembly. -->
  <PropertyGroup>
    <ProjectTypeGuids>{BAA0C2D2-18E2-41B9-852F-F413020CAA33};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{CC222EAD-CE14-41E9-A2A5-708AF623FF8F}</ProjectGuid>
    <OutputType>Library</OutputType>
    <NoStandardLibraries>false</NoStandardLibraries>
    <RootNamespace>WordAddIn1</RootNamespace>
    <AssemblyName>WordAddIn1</AssemblyName>
  </PropertyGroup>
  <PropertyGroup>
    <!-- 
        VSTO_TrustAssembliesLocation - If true, VSTO gives the project output full trust in user-
              level policy when the project is built.
        VSTO_HostDocumentName - Not used in addins.
    -->
    <VSTO_TrustAssembliesLocation>true</VSTO_TrustAssembliesLocation>
  </PropertyGroup>
  <PropertyGroup>
    <!--
        properites needed to register addins
        AddinRegistryHive - Root registry hive for the addin
        AddinRegistryKey  - Registry key where this addin is registered
    -->
    <AddinRegistryHive>CurrentUser</AddinRegistryHive>
    <AddinRegistryKey>Software\Microsoft\Office\Word\Addins</AddinRegistryKey>
  </PropertyGroup>
  <!-- This section defines properties that are set when the "Debug" configuration is 
       selected. 
       DebugSymbols - If true, create symbols (.pdb). If false, do not create symbols.
       Optimize - If true, optimize the build output. If false, do not optimize.
       OutputPath - Output path of project relative to the project file.
       EnableUnmanagedDebugging - If true, starting the debugger will attach both managed and unmanaged debuggers.
       DefineConstants - Constants defined for the preprocessor.
       Warning Level - Warning level for the compiler.
  -->
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>.\bin\Debug\</OutputPath>
    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <!-- This section defines properties that are set when the "Release" configuration is 
       selected.
       DebugSymbols - If true, create symbols (.pdb). If false, do not create symbols.
       Optimize - If true, optimize the build output. If false, do not optimize.
       OutputPath - Output path of project relative to the project file.
       EnableUnmanagedDebugging - If true, starting the debugger will attach both managed and unmanaged debuggers.
       DefineConstants - Constants defined for the preprocessor.
       Warning Level - Warning level for the compiler.
  -->
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>.\bin\Release\</OutputPath>
    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
    <DefineConstants>TRACE</DefineConstants>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <!-- This section enables pre and post build steps. However, 
       in VSTO use MSBuild tasks instead of these properties.       
  -->
  <PropertyGroup>
    <PreBuildEvent>
    </PreBuildEvent>
    <PostBuildEvent>
    </PostBuildEvent>
  </PropertyGroup>
  <!--
     This sections specifies references for the project.
  -->
  <ItemGroup>
    <Reference Include="Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\Common\Common\bin\Release\Common.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.XML" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Drawing" />
    <Reference Include="Accessibility" />
    <Reference Include="Microsoft.VisualStudio.Tools.Applications.Runtime" />
    <Reference Include="Microsoft.Office.Tools.Common" />
  </ItemGroup>
  <!--
     This section specifies COM References for the project (managed assemblies that wrap unmanaged
     typelibs (tlb)). This is the equivalent of choosing "Add Reference->Com Reference" in the 
     IDE.
  -->
  <ItemGroup>
    <COMReference Include="Microsoft.Office.Core">
      <Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
      <VersionMajor>2</VersionMajor>
      <VersionMinor>3</VersionMinor>
      <WrapperTool>primary</WrapperTool>
    </COMReference>
    <COMReference Include="Word">
      <Guid>{00020905-0000-0000-C000-000000000046}</Guid>
      <VersionMajor>8</VersionMajor>
      <VersionMinor>3</VersionMinor>
      <WrapperTool>primary</WrapperTool>
    </COMReference>
    <COMReference Include="stdole">
      <Guid>{00020430-0000-0000-C000-000000000046}</Guid>
      <VersionMajor>2</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <Lcid>0</Lcid>
      <WrapperTool>primary</WrapperTool>
      <Isolated>False</Isolated>
    </COMReference>
  </ItemGroup>
  <!--
     This section defines the user source files that are part of the
     project.
     
     A compile tag specifies a source file to compile.
     An EmbeddedResource tag specifies an .resx file for embedded resources.
     A None tag specifies a file that is not to be passed to the compiler (for instance, 
     a text file or XML file).
     The AppDesigner tag specifies the directory where the application properties files can
     be found.
  -->
  <ItemGroup>
    <Compile Include="CustomDocumentPropertyManager.cs" />
    <Compile Include="Properties\AssemblyInfo.cs">
      <SubType>Code</SubType>
    </Compile>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
    </Compile>
    <Compile Include="ThisAddIn.cs">
      <SubType>Code</SubType>
    </Compile>
    <None Include="ThisAddIn.Designer.xml">
      <DependentUpon>ThisAddIn.cs</DependentUpon>
    </None>
    <Compile Include="ThisAddIn.Designer.cs">
      <DependentUpon>ThisAddIn.Designer.xml</DependentUpon>
    </Compile>
    <AppDesigner Include="Properties\" />
  </ItemGroup>
  <!-- Include the build rules for a C# project.-->
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- Include additional build rules for an office application addin -->
  <Import Project="$(MSBuildExtensionsPath)\Microsoft.VisualStudio.OfficeTools2.targets" />
  <!-- This section defines VSTO properties that describe the host-changable project properties. -->
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
        <ProjectProperties HostName="Word" HostPackage="{D53BAEDE-5B63-42BE-8267-3DED11EDC582}" ApplicationType="Word" Language="cs" TemplatesPath="" DebugInfoExeName="#Software\Microsoft\Office\11.0\Word\InstallRoot\Path#WINWORD.EXE" DebugInfoCommandLine="/w" />
        <Host Name="Word" GeneratedCodeNamespace="WordAddIn1" IconIndex="0">
          <HostItem Name="ThisAddIn" Code="ThisAddIn.cs" CanonicalName="AddIn" CanActivate="false" IconIndex="1" Blueprint="ThisAddIn.Designer.xml" GeneratedCode="ThisAddIn.Designer.cs" />
        </Host>
        <ProjectClient>
          <VSTO_CompatibleProducts ErrorProduct="This project requires Microsoft Office Word 2003, but this application is not installed." ErrorPIA="This project references the primary interop assembly for Microsoft Office Word 2003, but this primary interop assembly is not installed.">
            <Product Code="{XXXXXXXX-6000-11D3-8CFE-0150048383C9}" Feature="WORDFiles" PIAFeature="Word_PIA" />
          </VSTO_CompatibleProducts>
        </ProjectClient>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
</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
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions