Sub Макрос12()
'
' Макрос12 Макрос
'
'
ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes.AddTextEffect( _
PowerPlusWaterMarkObject9355177, "ДЛЯ СЛУЖЕБНОГО ПОЛЬЗОВАНИЯ", "Calibri", _
1, False, False, 0, 0).Select
Selection.ShapeRange.Name = "PowerPlusWaterMarkObject9355177"
Selection.ShapeRange.TextEffect.NormalizedHeight = False
Selection.ShapeRange.Line.Visible = False
Selection.ShapeRange.Fill.Visible = True
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(192, 192, 192)
Selection.ShapeRange.Fill.Transparency = 0.5
Selection.ShapeRange.Rotation = 315
Selection.ShapeRange.LockAspectRatio = True
Selection.ShapeRange.Height = CentimetersToPoints(2.49)
Selection.ShapeRange.Width = CentimetersToPoints(20.77)
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapNone
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.Left = wdShapeCenter
Selection.ShapeRange.Top = wdShapeCenter
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
c++builder 2009, MS Word 2010, WaterMark
ОС win7, Office 2010, c++builder 2009.
Есть документ созданный в word 2000. в документе разрывы страниц.
Используя word 2010 вставлена в данный документ настраиваемая подложка (на все пространство документа она автоматически распределилась).
Записан макрос вставки этой подложки:
Код:
Код транслирован на с++builder:
Код:
WordDocument1->Application->Document->Selection->Range->Select();
WordDocument1->Application->ActiveWindow->ActivePane->View->SeekView =
WdSeekView::wdSeekCurrentPageHeader;
WordDocument1->Application->Selection->HeaderFooter->Shapes->AddTextEffect(
Office_xp::MsoPresetTextEffect::msoTextEffect2,
WideString(Memo1->Lines->Text).c_bstr(),
WideString("Arial").c_bstr(),
60.0,
MsoTriState::msoFalse,
MsoTriState::msoFalse,
0,
0)->Select();
WordDocument1->Application->Selection->ShapeRange->Name = WideString("PowerPlusWaterMarkObject1").c_bstr();
WordDocument1->Application->Selection->ShapeRange->TextEffect->NormalizedHeight = MsoTriState::msoFalse;
//WordDocument1->Application->Selection->ShapeRange->TextEffect->set_FontSize(50);
WordDocument1->Application->Selection->ShapeRange->Line->Visible = MsoTriState::msoFalse;
WordDocument1->Application->Selection->ShapeRange->Fill->Visible = MsoTriState::msoTrue;
WordDocument1->Application->Selection->ShapeRange->Fill->Solid();
WordDocument1->Application->Selection->ShapeRange->Fill->Transparency = 0.5;
WordDocument1->Application->Selection->ShapeRange->Rotation = 320;
WordDocument1->Application->Selection->ShapeRange->LockAspectRatio = MsoTriState::msoTrue;
WordDocument1->Application->Selection->ShapeRange->Height = WordDocument1->Application->CentimetersToPoints(2.58);
WordDocument1->Application->Selection->ShapeRange->Width = WordDocument1->Application->CentimetersToPoints(18.07);
WordDocument1->Application->Selection->ShapeRange->WrapFormat->AllowOverlap = MsoTriState::msoTrue;
WordDocument1->Application->Selection->ShapeRange->WrapFormat->Side = Word_xp::WdWrapSideType::wdWrapBoth; //wdWrapLargest
WordDocument1->Application->Selection->ShapeRange->WrapFormat->Type = Word_xp::WdWrapType::wdWrapNone; //wdWrapNone
WordDocument1->Application->Selection->ShapeRange->RelativeHorizontalPosition = Word_xp
::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin;
WordDocument1->Application->Selection->ShapeRange->RelativeVerticalPosition = Word_xp
::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin;
WordDocument1->Application->Selection->ShapeRange->Left = Word_xp::WdShapePosition::wdShapeCenter;
WordDocument1->Application->Selection->ShapeRange->Top = Word_xp::WdShapePosition::wdShapeCenter;
WordDocument1->Application->ActiveWindow->ActivePane->View->SeekView = WdSeekView::wdSeekMainDocument;
WordDocument1->Application->ActiveWindow->ActivePane->View->SeekView =
WdSeekView::wdSeekCurrentPageHeader;
WordDocument1->Application->Selection->HeaderFooter->Shapes->AddTextEffect(
Office_xp::MsoPresetTextEffect::msoTextEffect2,
WideString(Memo1->Lines->Text).c_bstr(),
WideString("Arial").c_bstr(),
60.0,
MsoTriState::msoFalse,
MsoTriState::msoFalse,
0,
0)->Select();
WordDocument1->Application->Selection->ShapeRange->Name = WideString("PowerPlusWaterMarkObject1").c_bstr();
WordDocument1->Application->Selection->ShapeRange->TextEffect->NormalizedHeight = MsoTriState::msoFalse;
//WordDocument1->Application->Selection->ShapeRange->TextEffect->set_FontSize(50);
WordDocument1->Application->Selection->ShapeRange->Line->Visible = MsoTriState::msoFalse;
WordDocument1->Application->Selection->ShapeRange->Fill->Visible = MsoTriState::msoTrue;
WordDocument1->Application->Selection->ShapeRange->Fill->Solid();
WordDocument1->Application->Selection->ShapeRange->Fill->Transparency = 0.5;
WordDocument1->Application->Selection->ShapeRange->Rotation = 320;
WordDocument1->Application->Selection->ShapeRange->LockAspectRatio = MsoTriState::msoTrue;
WordDocument1->Application->Selection->ShapeRange->Height = WordDocument1->Application->CentimetersToPoints(2.58);
WordDocument1->Application->Selection->ShapeRange->Width = WordDocument1->Application->CentimetersToPoints(18.07);
WordDocument1->Application->Selection->ShapeRange->WrapFormat->AllowOverlap = MsoTriState::msoTrue;
WordDocument1->Application->Selection->ShapeRange->WrapFormat->Side = Word_xp::WdWrapSideType::wdWrapBoth; //wdWrapLargest
WordDocument1->Application->Selection->ShapeRange->WrapFormat->Type = Word_xp::WdWrapType::wdWrapNone; //wdWrapNone
WordDocument1->Application->Selection->ShapeRange->RelativeHorizontalPosition = Word_xp
::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin;
WordDocument1->Application->Selection->ShapeRange->RelativeVerticalPosition = Word_xp
::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin;
WordDocument1->Application->Selection->ShapeRange->Left = Word_xp::WdShapePosition::wdShapeCenter;
WordDocument1->Application->Selection->ShapeRange->Top = Word_xp::WdShapePosition::wdShapeCenter;
WordDocument1->Application->ActiveWindow->ActivePane->View->SeekView = WdSeekView::wdSeekMainDocument;
Код на с++ корректно работает с документами созданными в Word 2010 и имеющими разрывы страниц.
При работе с документом, созданным в word 2000, вставка подложки происходит только до первого разрыва.
Вопрос: как корректно распределить подложки по всем разрывам документа, созданного в Word 2000?
Заранее спасибо!