بانک آموزشی

بانک آموزشی

نرم افزار - سخت افزار - طراحی - برنامه نویسی _ ویروس شناسی ...
بانک آموزشی

بانک آموزشی

نرم افزار - سخت افزار - طراحی - برنامه نویسی _ ویروس شناسی ...

اجرای برنامه word وباز کردن یک فایل



Var

MSWord : Variant

procedure TTMDtlForm.ExecuteTheMacro;
var
WHandle : HWnd;
begin
try
// If file selected
If OpenDialog1.execute Then
begin
// Set Flag to False
FoundWord:=False;

try
// If word is already running, obtain a link and set flag to true
MsWord := GetActiveOleObject('Word.Basic');
FoundWord := True;
except
try
// Start new instance of word and set flag to True
MsWord := CreateOleObject('Word.Basic');
FoundWord := True;
except
// Display error message
ShowMessage('Could not start word');
end;
end;

// If Link established
if FoundWord then
begin
try
MsWord.AppShow;
MsWord.ScreenUpdating(0);
MSWord.FileOpen(OpenDialog1.FileName);
MsWord.ScreenUpdating(1);
MsWord.ScreenRefresh;

// Maximize and bring Word to front
WHandle := FindWindow('OpusApp',Nil);
if isWindow(WHandle) then
ShowWindow(WHandle,SW_SHOWMAXIMIZED);
except
MessageDlg('TF - Error in Word Basic',mtError,[mbOK],0);
MsWord.ScreenUpdating(1);
end;
end;
end;
finally
end;
end;

نظرات 0 + ارسال نظر
برای نمایش آواتار خود در این وبلاگ در سایت Gravatar.com ثبت نام کنید. (راهنما)
ایمیل شما بعد از ثبت نمایش داده نخواهد شد