Интернет-журнал 'Домашняя лаборатория', 2007 №3 - Вудворт
Шрифт:
Интервал:
Закладка:
����� ����, �� ������ �� ������� ���, ����� ��� ������� ��������� ���� "����������� �����" �� ��������� ������ �� �� ���������� � �������� ���������� � �� ������ �� ����� ��������� ��� �������������� ��������� � ��������� �����! ��� ������ ����� � ��������� �������� "Directory" ��� "ActiveDocument.Name" ����� ��������".Display":
With Dialogs(wdDialogCopyFile)
.Directory = ActiveDocument.Path
.Display
papka =.Directory
End With
If Right(papka, 1) = Chr$(34) Then papka = Mid(papka, 2, Len(papka) � 2)
��� � ���� ����������� ��� ��� ����������� ����������� ���� � ��������� ���� � ����� ��� ���������� ������������ ����������. �������, ������� ���, ����� ������� ������ "������" � ���������� ���� ��������� �� �� � �������� ����������� ������ ���������, � � ������ �� ���. ��� ����� � ������� �� �����".Display" ������, ��� ��� ������� �������� �������� � �� ���� ���������� ������������ ��������, � ����������� �� ����, ����� ������ ���� ������. ������� � ��������� ������� � ������� ������ �� ���������:
With Dialogs(wdDialogCopyFile)
.Directory = ActiveDocument.Path
If .Display = 0 Then Exit Sub
papka = .Directory
End With
If Right(papka, 1) = Chr$(34) Then papka = Mid(papka, 2, Len(papka) � 2)
������ ��� ������� ������ "������" � ���������� ���� ������ ����� ���������� ����� �� ���������.
������������� ��� ������ �������:
Sub ������1()
' ��������� ��� ��������� ����������
With Dialogs(wdDialogCopyFile)
.Directory = ActiveDocument.Path
If .Display = 0 Then Exit Sub
papka = .Directory
End With
If Right(papka, 1) = Chr$(34) Then papka = Mid(papka, 2, Len(papka) � 2)
metka:
Selection.Wholestory
With Selection.Font
� .Name = "Times New Roman"
� .Size = 12
� .Colorlndex = wdBlack
End With
With Selection.ParagraphFormat
� .Leftlndent = CentimetersToPoints(0)
� .Rightlndent = CentimetersToPoints(0)
� .SpaceBefore = 0.SpaceAfter = 0
� .LineSpacingRule = wdLineSpaceSingle
� .FirstLinelndent = CentimetersToPoints(1.27)
End With
Selection.Find.ClearFormatting
Selection.Find.ParagraphFormat.Alignment = wdAlignParagraphLeft
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.ParagraphFormat.Alignment = wdAlignParagraphJustify
With Selection.Find.
� .Text = ""
� .Replacement.Text = ""
� .Forward = True
� .Wrap = wdFindContinue
� .Format = True
� .MatchCase = False
� .MatchWholeWord = False
� .MatchWildcards = False
� .MatchSoundsLike = False
� .MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveDocument.Save
ActiveDocument.SaveAs FileName:=papka + Left(ActiveDocument.Name,
Len(ActiveDocument.Name) � 4), FileFormat:=wdFormatRTF
ActiveWindow.Close
If Documents.Count > 0 Then GoTo metka
signal = MsgBox("��������� ���������", vblnformation, "��������� �������")
End Sub
* * *
���� ����������� ���� ��������� ������ ��������� ������ ������������, ��������, ����-�� ������������ ������� ���������, ������� ����� ������������� ��� ����, ����� �������� ��� ������ ��� ����������� ���� ��� ����������� � ������, ����������� ��� �������� �����������, � ��� ����� ������� ��������� ������ ������� ������������ ���� � ���������������� �������� ���������������� �� VBA. ���� ����� ���������� �� �� ���������������� �������������, �������, ��� ��������, ����� ��� ������, � ������ �� ���, ��� ����� ������ �� ���� ������������� �� ���� ������� ������������ ������������.
� ��� ������ ������:
1.���� ������ ������� ������ ������, � ����� ��� ���������, ����� ������� ������������� ���� ��� ����� �������������� ������ ��� ������� �������� ������������ Word, ���������� ������ ������������ �������� ������� ��������� VBA �� ���������� ������ ������ ���������������� � �������� ������ ��������. ������� �������� ������ �������� ��������� ������ � ����� ������� ���� ������ ��������� � ������ �� �������, � ����� ����� ������� ��������� ������, ����� ���������� "���������" �� ���� VBA �����-���� �������� ������������ Word.
2.���� ���������� ��������� ����, ��������� ��������� ����������� ������ ������� ������� ������ ������������ ����������� ��������� VBA, ������� ���������� ��� ������ ����� ��� ������ ����� ��� ���������� ����� �������.
3.�������� VBA � �������� �������� ������ �� ����� �����! ���