This commit is contained in:
2007-12-03 16:28:26 +00:00
parent 7b55aba5b7
commit 469b8a60ff
13 changed files with 1927 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2F79D7F9-885E-4441-99F3-045D7612B2E5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MSWord</RootNamespace>
<AssemblyName>MSWord</AssemblyName>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\..\veproms\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WordDoc.cs" />
</ItemGroup>
<ItemGroup>
<COMReference Include="Microsoft.Office.Core">
<Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>3</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="VBIDE">
<Guid>{0002E157-0000-0000-C000-000000000046}</Guid>
<VersionMajor>5</VersionMajor>
<VersionMinor>3</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="Word">
<Guid>{00020905-0000-0000-C000-000000000046}</Guid>
<VersionMajor>8</VersionMajor>
<VersionMinor>3</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- 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>

View File

@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using Microsoft.Office.Interop;
using Microsoft.Office.Interop.Word;
namespace Volian.MSWord
{
public class WordDoc
{
private object optional = Missing.Value;
private object oFalse = false;
private object oTrue = true;
private object oBlank = "";
private object oWdStory = WdUnits.wdStory;
private object oWdWord = WdUnits.wdWord;
private object oWdChar = WdUnits.wdCharacter;
private object oWdLine = WdUnits.wdLine;
private object oWdPara = WdUnits.wdParagraph;
private object oWdExtend = WdMovementType.wdExtend;
private object oWdMove = WdMovementType.wdMove;
private object o1 = 1;
private Application m_App;
// Microsoft.Office.Interop.Word.Application App
// {
// get{return m_App;}
// }
private Document m_Doc;
// Microsoft.Office.Interop.Word.Document Doc
// {
// get{return m_Doc;}
// }
private string mDocName;
public string DocName
{
get { return mDocName; }
set { mDocName = value; }
}
public WordDoc(string sPath)
{
m_App = new ApplicationClass();
//m_App.Visible = true;
mDocName = sPath;
object oFile = sPath;
m_Doc = m_App.Documents.Open(
ref oFile // FileName
,ref optional // ConfirmConversions
,ref optional // ReadOnly
,ref optional // AddToRecentFiles
,ref optional // PasswordDocument
,ref optional // PasswordTemplate
,ref optional // Revert
,ref optional // WritePasswordDocument
,ref optional // WritePasswordTemplate
,ref optional // Format
,ref optional // Encoding
,ref optional // Visible
,ref optional // OpenAndRepair
,ref optional // DocumentDirection
,ref optional // NoEncodingDialog
,ref optional // XMLTransform
);
}
//~WordDoc()
//{
// m_App.Quit(ref oFalse, ref optional, ref optional);
//}
private string SaveDoc()
{
object oFileName = mDocName;
object oFileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument;
//object oFileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatFilteredHTML;
object oPassWord = "";
try
{
m_Doc.SaveAs2000(
ref oFileName // FileName
,ref oFileFormat // FileFormat
,ref oFalse // LockComments
,ref oPassWord // Password
,ref oFalse // AddToRecentFiles
,ref oPassWord // WritePassword
,ref oFalse // ReadOnlyRecommended
,ref oFalse // EmbedTrueTypeFonts
,ref oFalse // SaveNativePictureFormat
,ref oFalse // SaveFormsData
,ref oFalse // SaveAsAOCELetter
);
return "Successful Save";
}
catch (Exception ex)
{
return string.Format("Error during Doc save - {0}", ex.Message);
}
}
public string Save()
{
return SaveDoc();
}
public string Save(string sPath)
{
mDocName = sPath;
return SaveDoc();
}
public void Close()
{
m_App.Quit(ref oFalse, ref optional, ref optional);
}
}
}