1. (Before I code my own) is there any function to open a Word Document (e.g. using automation)?
2. Does anyone have a good method to "guess" whether to default to Inches or CM? I'm thinking of using Inches if the Locale is USA, otherwise CM...
1. (Before I code my own) is there any function to open a Word Document (e.g. using automation)?
2. Does anyone have a good method to "guess" whether to default to Inches or CM? I'm thinking of using Inches if the Locale is USA, otherwise CM...
1. (Before I code my own) is there any function to open a Word Document (e.g. using automation)?
No guarantee with this:
var
oWord: OleVariant;
oDoc: OleVariant;
begin
Result := False;
try
oWord := GetActiveOleObject('Word.Application');
except
oWord := CreateOleObject('Word.Application');
end;
oWord.Documents.Open(FileName);
oDoc := oWord.ActiveDocument;
FileName := ChangeFileExt(FileName, '.rtf');
oDoc.SaveAs(FileName);
oWord.ActiveDocument.Close(wdDoNotSaveChanges, EmptyParam, EmptyParam);
oWord.Quit(EmptyParam, EmptyParam, EmptyParam);
oDoc := VarNull;
oWord := VarNull;
Result := True;
end;
Alles anzeigen
Zitat2. Does anyone have a good method to "guess" whether to default to Inches or CM? I'm thinking of using Inches if the Locale is USA, otherwise CM...
Check out GetLocaleFormatSettings in SysUtils.pas
It calls GetLocaleInfo API.
Julian
Hi Julian
1. Yes, this is way I do it, albeit with a temporary file.
2. I default to inches if LocaleIsUSA=True
function LocaleIsUSA: Boolean;
const
English_United_States_Locale = 1033;
begin
try
Result := GetUserDefaultLCID = English_United_States_Locale;
except
Result := False;
end;
end;