#include
#pragma hdrstop
#include
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Word_XP_srvr"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(OpenDialog1->Execute())
Edit1->Text = OpenDialog1->FileName;
String str_errors;
String str=OpenDialog1->FileName;
Variant VarApp,VarDoc;
try
{
VarApp=CreateOleObject("Word.Application");
VarDoc=VarApp.OlePropertyGet("Documents");
VarDoc.OleProcedure("Open", WideString(str));
VarApp.OlePropertySet("Visible",true);
}
catch(Exception &ex)
{
str_errors=ex.Message;
ShowMessage(str_errors);
} }
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
WideString macr;
macr="BIR";
WordApplication1->Run(macr.c_bstr());
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
WideString macr;
macr="IKKI";
WordApplication1->Run(macr.c_bstr());
}
//-------------------------------------------------------------
Dastur yaratilishi jarayonida qo’shimcha sifatida Word dasturida Normal.dotm
shablonidan ham foydalanildi, quiyda foydalanilgan makroslar kodini keltiramiz.
Sub BIR()
Dim x As Integer, y As Integer
Dim a As Integer
Dim i As Integer
ActiveDocument.Bookmarks("\EndOfDoc").Select
x = ActiveDocument.Range.Information(wdNumberOfPagesInDocument)
' MsgBox x
Do While Not (x Mod 4 = 0)
Selection.InsertBreak Type:=wdPageBreak
x = x + 1
Loop
a = x
Dim h As String
Dim BIR(1 To 1000) As Integer
For i = 1 To a
BIR(i) = i
Next
' 1 2 3 4 5 6 7 8 9 10 11 12
' 12,1,10,3,8,5
For i = 1 To a / 2
h = h & CStr(BIR(a - i + 1)) & ","
If (BIR(i) = a / 2 - 1) Then
h = h & CStr(BIR(i))
Else
h = h & CStr(BIR(i)) & ","
End If
i = i + 1
Next
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentWithMarkup, Copies:=1, Pages:=h, PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
PrintZoomColumn:=2, PrintZoomRow:=1, PrintZoomPaperWidth:=0, _
|