Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi Ms word自动页面设置和保存在windows 10中_Delphi_Ms Word - Fatal编程技术网

Delphi Ms word自动页面设置和保存在windows 10中

Delphi Ms word自动页面设置和保存在windows 10中,delphi,ms-word,Delphi,Ms Word,如何在Delphi Word automation中设置页面,如legal、A4等-在CreateOleObject(“Word.Application”)之后,并将Delphi创建的Word文档以特定名称保存在C驱动器中 下面的代码将创建具有指定纸张大小的文档,并将其保存在指定名称下: uses ... Word2000; procedure TForm1.CreateDocWithPaperSize; var MSWord, Document, PageSetUp: OleVa

如何在Delphi Word automation中设置页面,如legal、A4等-在CreateOleObject(“Word.Application”)之后,并将Delphi创建的Word文档以特定名称保存在C驱动器中

下面的代码将创建具有指定纸张大小的文档,并将其保存在指定名称下:

uses ... Word2000;

procedure TForm1.CreateDocWithPaperSize;
var
  MSWord,
  Document,
  PageSetUp: OleVariant;
  AFileName : String;
  iDocument : WordDocument;
begin
  MsWord := CreateOleObject('Word.Application');
  MsWord.Visible := True;

  Document := MSWord.Documents.Add;
  MSWord.Selection.Font.Size := 22;
  MSWord.Selection.Font.Bold := true;
  MSWord.Selection.TypeText(#13#10);

  // the following is to get the WordDocument interface 'inside' the
  //  Document variant, so that we can use code completion on
  // iDocument in the IDE to inspect its properties
  iDocument := IDispatch(Document) as WordDocument;

  PageSetUp := iDocument.PageSetup;
  PageSetUp.PaperSize := wdPaperLegal;
  MSWord.Selection.TypeText('Hello Word.');

  AFileName := 'C:\Temp\Test.Docx';
  Document.SaveAs(FileName := AFileName);
end;
Word2000.Pas
是MS Word类型库的导入单元(还有其他版本-请参阅Delphi设置中OCX文件夹下的Servers子文件夹)。在其中,搜索

wdPaperSize

,您会发现它声明为
TOleEnum
。在其下方,您将看到一个常数列表,可用于指定特定的纸张尺寸

{ From Word2000.Pas }
// Constants for enum WdPaperSize
type
  WdPaperSize = TOleEnum;
const
  wdPaper10x14 = $00000000;
  wdPaper11x17 = $00000001;
  wdPaperLetter = $00000002;
  wdPaperLetterSmall = $00000003;
  wdPaperLegal = $00000004;
  wdPaperExecutive = $00000005;
  wdPaperA3 = $00000006;
  wdPaperA4 = $00000007;
  wdPaperA4Small = $00000008;
  wdPaperA5 = $00000009;
  wdPaperB4 = $0000000A;
  wdPaperB5 = $0000000B;
  wdPaperCSheet = $0000000C;
  // etc

下面的代码将创建具有指定纸张大小的文档,并将其保存在指定名称下:

uses ... Word2000;

procedure TForm1.CreateDocWithPaperSize;
var
  MSWord,
  Document,
  PageSetUp: OleVariant;
  AFileName : String;
  iDocument : WordDocument;
begin
  MsWord := CreateOleObject('Word.Application');
  MsWord.Visible := True;

  Document := MSWord.Documents.Add;
  MSWord.Selection.Font.Size := 22;
  MSWord.Selection.Font.Bold := true;
  MSWord.Selection.TypeText(#13#10);

  // the following is to get the WordDocument interface 'inside' the
  //  Document variant, so that we can use code completion on
  // iDocument in the IDE to inspect its properties
  iDocument := IDispatch(Document) as WordDocument;

  PageSetUp := iDocument.PageSetup;
  PageSetUp.PaperSize := wdPaperLegal;
  MSWord.Selection.TypeText('Hello Word.');

  AFileName := 'C:\Temp\Test.Docx';
  Document.SaveAs(FileName := AFileName);
end;
Word2000.Pas
是MS Word类型库的导入单元(还有其他版本-请参阅Delphi设置中OCX文件夹下的Servers子文件夹)。在其中,搜索

wdPaperSize

,您会发现它声明为
TOleEnum
。在其下方,您将看到一个常数列表,可用于指定特定的纸张尺寸

{ From Word2000.Pas }
// Constants for enum WdPaperSize
type
  WdPaperSize = TOleEnum;
const
  wdPaper10x14 = $00000000;
  wdPaper11x17 = $00000001;
  wdPaperLetter = $00000002;
  wdPaperLetterSmall = $00000003;
  wdPaperLegal = $00000004;
  wdPaperExecutive = $00000005;
  wdPaperA3 = $00000006;
  wdPaperA4 = $00000007;
  wdPaperA4Small = $00000008;
  wdPaperA5 = $00000009;
  wdPaperB4 = $0000000A;
  wdPaperB5 = $0000000B;
  wdPaperCSheet = $0000000C;
  // etc

哪些Delphi和MS Word版本?Delphi Xe10.2和MS office 2016哪些Delphi和MS Word版本?Delphi Xe10.2和MS office 2016谢谢。我正在使用windows 10。保存到C驱动器显示错误-写保护。但我可以保存在D或E驱动器中:,如何才能保存在windows 10-,C驱动器中?C:驱动器上的确切位置?阅读有关写入访问权限的信息。顺便说一句,这是一个完全不同于您在q中提出的问题。我的意思是“C:\Temp\Test.Docx”;在windows 10中不可能右键单击资源管理器中的C:\Temp,选择属性并查看安全选项卡。这将告诉你谁拥有或没有该文件夹的写入权限。delphi ms word Automation的最佳参考手册或链接是什么?谢谢。我使用的是windows 10。保存到C驱动器显示错误-写保护。但我可以保存在D或E驱动器中:,如何才能保存在windows 10-,C驱动器中?C:驱动器上的确切位置?阅读有关写入访问权限的信息。顺便说一句,这是一个完全不同于您在q中提出的问题。我的意思是“C:\Temp\Test.Docx”;在windows 10中不可能右键单击资源管理器中的C:\Temp,选择属性并查看安全选项卡。这将告诉你谁有,谁没有对文件夹的写入权限。delphi ms word automation的最佳参考手册或链接是什么