Word �iVBA�j

Word VBA�Ɋւ���t�H�[�����ł��B
  • �����ς݂̃g�s�b�N�ɂ̓R�����g�ł��܂���B
���̃g�s�b�N�͉����ς݂ł��B
����

 
(Windows 11 Home : Word 2013)
�e�L�X�g�{�b�N�X���̍s���Ƃ̏����ϊ�
���e����: 25/08/21 12:11:09
���e��: Tetsuyan

���߂܂��āA��낵�����肢�������܂��B
 
���܁AWord�������ɕ����̃e�L�X�g�{�b�N�X���z�u����Ă���A
���ꂼ��ɗ�O�Ȃ�
�y�w�Z�z�������w�Z
�y���O�z�������Z
�ƁA2�s�̕����񂪓��������œ��͂���Ă��܂��B
�����1�s�ڂ́y�w�Z�z�̍s�����t�H���g�ƃT�C�Y���܂Ƃ߂ĕύX�������Ǝv���Ă��܂��B
Split�𗘗p���čs���Ƃ̕�����擾�܂ł͍l�����ł����A
���̂��Ƃ̑��삪�A���낢�뒲�ׂĂ����f�ł��܂���B
�������������������B
 
Dim shp As Shape
Dim textBoxText As String
Dim myArray() As String
 
  Set doc = ActiveDocument
  
  For Each shp In doc.Shapes
      If shp.Type = msoTextBox Then
 �@�@�@textBoxText = shp.TextFrame.TextRange.Text
          myArray = Split(textBoxText, vbCrLf)
          ---------------------------
    End If
  Next shp
 
  Set doc = Nothing
  Set shp = Nothing
 
�Ȃ��A���z�Ƃ��Ă�
�u�������w�Z�v�����ׂāu�������v�ɕύX�������̂ł����A
����́A�ʓr���₩�Ǝv���Ă܂��B
�X�������肢�v���܂��B

��
���e����: 25/08/21 18:58:36
���e��: sk

���p:
Word�������������̃e�L�X�g�{�b�N�X���z�u����Ă���A

�E�����̃e�L�X�g�{�b�N�X�������񃌃C���[���`�惌�C���[�̂ǂ���ɔz�u����Ă���̂��B
�@�i[������̐܂�Ԃ�]�v���p�e�B���u�s���v�ɐݒ肳��Ă��邩�ۂ��j
 
�E�����̃e�L�X�g�{�b�N�X�ȊO�̐}�`�i�I�[�g�V�F�C�v�A�摜�A�I�u�W�F�N�g�Ȃǁj��
�@���� Word ������Ɋ܂܂�Ă��Ȃ��̂��B
 
���p:
���ꂼ��ɗ�O�Ȃ�
�y�w�Z�z�������w�Z
�y���O�z�������Z
�ƁA2�s�̕����������������œ��͂���Ă��܂��B

 
�E�u 2 �‚��i��������i Enter �L�[�Ŏ��̒i���ɑ����Ă���j�v��
�@�u 1 �‚̒i���� 2 �‚��s�ō\������Ă���i Shift + Enter �L�[�Ŏ��̍s�ɑ����Ă���j�v��
�@�ǂ�����Ӗ����Ă���̂��B
 
�ȏ�� 3 �_�ɂ‚��Ė��L����邱�Ƃ������߂��܂��B
 
�Ƃ肠�����A���̂悤�ȏ�Ԃł���Ɖ��肵�܂��B
 
�E���� Word ������Ƀe�L�X�g�{�b�N�X�ȊO�̐}�`�͔z�u����Ă��Ȃ��B
 
�E�S�Ẵe�L�X�g�{�b�N�X�͕`�惌�C���[�ɔz�u����Ă���
�@�i[������̐܂�Ԃ�]�v���p�e�B���u�s���v�ȊO�̒l�ɐݒ肳��Ă���j�B
 
�E�S�Ẵe�L�X�g�{�b�N�X�̃��C�A�E�g�g�̕������ 2 �‚̒i���ō\������Ă���B
 
���p:
�����1�s�ڂ́y�w�Z�z�̍s�����t�H���g�ƃT�C�Y���܂Ƃ߂ĕύX������

���p:
�u�������w�Z�v�����ׂāu�������v�ɕύX������

�i�W�����W���[���j
--------------------------------------------------------------------------
Sub SetFirstParagraphInShapes()
    
    Dim docTarget As Word.Document
    
    '�A�N�e�B�u�� Word �������Q��
    Set docTarget = ActiveDocument
    
    Dim shpLoop As Word.Shape
    Dim tfTarget As Word.TextFrame
    Dim prgFirst As Word.Paragraph
    Dim rngTarget As Word.Range
    
    '�����̕`�惌�C���[��̑S�Ă̐}�`���Q�Ƃ���
    For Each shpLoop In docTarget.Shapes
               
        '���C�A�E�g�g�̎Q��
        Set tfTarget = shpLoop.TextFrame
               
        '���C�A�E�g�g�ɕ����񂪑}������Ă���ꍇ
        If tfTarget.HasText = True Then
            '���� 1 �‚߂̒i�����Q�Ƃ���
            Set prgFirst = tfTarget.TextRange.Paragraphs(1)
        End If
        
        '1�‚߂̒i�����Q�Ƃł����ꍇ
        If Not prgFirst Is Nothing Then
            
            '���̒i���S�̂̕�����͈͂��Q��
            Set rngTarget = prgFirst.Range
            
            '�t�H���g�̐ݒ�
            With rngTarget.Font
                .Name = "�l�r ����"
                .Size = 12
            End With
            
            '[�����ƒu��]�̐ݒ�
            With rngTarget.Find
                .ClearFormatting
                .ClearAllFuzzyOptions
                .MatchByte = True
                .MatchCase = False
                .MatchFuzzy = False
                .MatchWholeWord = False
                .MatchWildcards = False
                .Forward = False
                With .Replacement
                    .ClearFormatting
                End With
                '������͈͂Ɋ܂܂�Ă�"���w�Z"��S��"��"�ɒu������
                .Execute FindText:="���w�Z", ReplaceWith:="��", Replace:=wdReplaceAll
            End With
            
            Set rngTarget = Nothing
            
        End If
        
        Set prgFirst = Nothing
        Set tfTarget = Nothing
    
    Next

    Set docTarget = Nothing

End Sub
--------------------------------------------------------------------------

��
���e����: 25/08/21 19:49:03
���e��: Suzu

���p:
�����1�s�ڂ́y�w�Z�z�̍s�����t�H���g�ƃT�C�Y���܂Ƃ߂ĕύX
�Ƃ̎��Ȃ̂ŁB
 
Shape �ɑ΂� �I�����s���΁ASelection ���g����l�ɂȂ�܂��B
��������AHomeKey ���g�����@���B
 
Sub Sample()
  Dim shp As Shape

  For Each shp In ActiveDocument.Shapes
    shp.Select
    With Selection
      .HomeKey unit:=wdLine, Extend:=wdMove
      .Extend Character:=vbCr
      .Font.Name = "Arial"
      .Font.Size = 30
    End With
  Next
End Sub

 
�u�w�Z�v�̕������܂܂�锻�肪�K�v�ł���� �K�v�ɉ����A��������Ă��������B

���e����: 25/08/23 20:34:40
���e��: Tetsuyan

sk�l�ASuzu�l�A
�񓚂��������A���肪�Ƃ��������܂��B
�܂��A�ԓ����x���Ȃ�\���󂲂����܂���B
 
sk�l�̃R�[�h���̂܂܂ŁA
�]�񂾒ʂ�̌��ʂɂȂ�܂����B
 
�����ԁA����ꓬ������������Ȃ��Ȃ邭�炢
����������������������A
�����Ɗ��ӂł��B
 
���肪�Ƃ��������܂����B