שיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....
-
קוד להוספת כותרות צד
Option Explicit Sub כותרות_צד() Dim numColumns As Integer, currentPara As Paragraph, slctd As Range _ 'set range Set slctd = Selection.Range 'start loop For Each currentPara In slctd.Paragraphs Application.ScreenUpdating = False currentPara.Range.Select 'get column width numColumns = ActiveDocument.PageSetup.TextColumns.Count If numColumns = 2 Then Dim columnWidth As Single Dim columnWidth2 As Single columnWidth = ActiveDocument.PageSetup.TextColumns.Item(1).Width columnWidth2 = ActiveDocument.PageSetup.TextColumns.Item(2).Width End If 'exceptions If Not currentPara.Range.ComputeStatistics(wdStatisticLines) > 1 _ Or Not currentPara.Range.ComputeStatistics(wdStatisticLines) > 2 Then GoTo nxt 'Get the first sentence of the current paragraph Dim firstSentence As String Dim words() As String words = Split(currentPara.Range.Text, " ") firstSentence = words(0) & " " & words(1) & " " & words(2) & " " _ & words(3) & " " & words(4) & " " & words(5) 'get font size set box font size and calc misalignment adjustment accordingly Dim fontSize, x, y, z As Single fontSize = currentPara.Range.Font.SizeBi - 4 x = currentPara.Range.Font.SizeBi y = x - 8 z = y * 0.4 'MsgBox z ' 'Dim spaceWidth As Double 'spaceWidth = currentPara.Range.font.spacing 'Dim spaceWidth As Double 'spaceWidth = ActiveDocument.PageSetup.TextColumns.spacing / 2 ' 'get middle of page Dim mrgn As Double mrgn = ActiveDocument.PageSetup.LeftMargin / 2 Dim newShape As Shape 'left column - if para calc is smaller then middle of page If ActiveDocument.PageSetup.PageWidth / 2 > currentPara.Range.Information(wdHorizontalPositionRelativeToPage) Then Set newShape = ActiveDocument.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _ Left:=currentPara.Range.Information(wdHorizontalPositionRelativeToPage) - columnWidth2 - mrgn, _ Top:=currentPara.Range.Information(wdVerticalPositionRelativeToPage), _ Width:=mrgn, Height:=50) newShape.TextFrame.TextRange.ParagraphFormat.Alignment = wdAlignParagraphRight End If 'right column - if para calc is larger If ActiveDocument.PageSetup.PageWidth / 2 < currentPara.Range.Information(wdHorizontalPositionRelativeToPage) Then Set newShape = ActiveDocument.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _ Left:=currentPara.Range.Information(wdHorizontalPositionRelativeToPage), _ Top:=currentPara.Range.Information(wdVerticalPositionRelativeToPage), _ Width:=mrgn, Height:=50) newShape.TextFrame.TextRange.ParagraphFormat.Alignment = wdAlignParagraphLeft End If 'newShape.TextFrame.MarginLeft = 0 'newShape.TextFrame.MarginRight = 0 newShape.TextFrame.MarginTop = z 'adjust misalignment newShape.TextFrame.MarginBottom = 0 newShape.Line.Visible = msoFalse newShape.TextFrame.TextRange.Text = firstSentence newShape.TextFrame.TextRange.Font.SizeBi = 8 newShape.TextFrame.AutoSize = True 'tiny adjustment If ActiveDocument.PageSetup.PageWidth / 2 > currentPara.Range.Information(wdHorizontalPositionRelativeToPage) Then newShape.TextFrame.MarginTop = newShape.TextFrame.MarginTop - 0.1 Else newShape.TextFrame.MarginTop = newShape.TextFrame.MarginTop - 0.05 newShape.TextFrame.MarginLeft = newShape.TextFrame.MarginLeft + 0.04 End If nxt: Application.ScreenUpdating = True Application.ScreenRefresh Next currentPara End Sub Sub מחק_כותרת_צד_בכל_המסמך() Dim shp As Shape, i As Integer, shppos, mrgnright, mrgnleft As Single mrgnleft = ActiveDocument.PageSetup.LeftMargin mrgnright = ActiveDocument.PageSetup.PageWidth - mrgnleft For i = ActiveDocument.Shapes.Count To 1 Step -1 Set shp = ActiveDocument.Shapes(i) shppos = shp.TextFrame.TextRange.Information(wdHorizontalPositionRelativeToPage) If shppos > mrgnright Or shppos < mrgnleft _ And shp.Type = msoTextBox And shp.Line.Visible = msoFalse Then 'And shp.Width = ActiveDocument.PageSetup.LeftMargin / 2 Then shp.Delete End If Next i End Sub Sub מחק_כותרות_צד_בעמוד_זה() Dim shp As Shape, i, currentPage As Integer, _ shppos, mrgnright, mrgnleft As Single mrgnleft = ActiveDocument.PageSetup.LeftMargin mrgnright = ActiveDocument.PageSetup.PageWidth - mrgnleft currentPage = Selection.Information(wdActiveEndPageNumber) Application.ScreenUpdating = False For Each shp In ActiveDocument.Shapes shppos = shp.TextFrame.TextRange.Information(wdHorizontalPositionRelativeToPage) If shp.Anchor.Information(wdActiveEndPageNumber) = currentPage And _ shppos > mrgnright Or shppos < mrgnleft _ And shp.Type = msoTextBox And shp.Line.Visible = msoFalse _ And shp.Anchor.Information(wdActiveEndPageNumber) = currentPage Then shp.Select (False) End If Next shp Application.ScreenUpdating = True Selection.Delete Unit:=wdCharacter, Count:=1 End Sub
@pcinfogmach כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
קוד להוספת כותרות צד
לא הבנתי מה בדיוק המטרה של זה, מה רע בליצור סגנון במסגרת??
-
@pcinfogmach כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
קוד להוספת כותרות צד
לא הבנתי מה בדיוק המטרה של זה, מה רע בליצור סגנון במסגרת??
פוסט זה נמחק! -
פוסט זה נמחק!
@pcinfogmach האם זה מה שאתה רוצה לעשות?
-
@pcinfogmach האם זה מה שאתה רוצה לעשות?
פוסט זה נמחק! -
הקטנת והגדלת סוגריים
מאחר ומדובר ביוזרפורם אני מעלה את הקובץ במקום קוד
יש לחלץ את כל הקבצים ואז להתקין את הקובץ frmעריכה: גירסה מעודכנת
MyParenthesis.zip -
הקטנת והגדלת סוגריים
מאחר ומדובר ביוזרפורם אני מעלה את הקובץ במקום קוד
יש לחלץ את כל הקבצים ואז להתקין את הקובץ frmעריכה: גירסה מעודכנת
MyParenthesis.zip@pcinfogmach כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
הקטנת והגדלת סוגריים
מאחר ומדובר ביוזרפורם אני מעלה את הקובץ frm במקום קוד
Parenthesis.frmErrors during load. Refer to
Line 8: Property OleObjectBlob in Parenthesis had an invalid file reference. -
@pcinfogmach כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
הקטנת והגדלת סוגריים
מאחר ומדובר ביוזרפורם אני מעלה את הקובץ frm במקום קוד
Parenthesis.frmErrors during load. Refer to
Line 8: Property OleObjectBlob in Parenthesis had an invalid file reference. -
@דאנציג
נראה לי שיש לו קובץ תומך שהיה חסר נסה עכשיו@pcinfogmach
את הקובץ עם הסיומת FRX ויז'ואל בייסיק לא נותן להוסיף עם השגיאה הנ"ל.
הקובץ השני מוסיף את זה:
-
@pcinfogmach
את הקובץ עם הסיומת FRX ויז'ואל בייסיק לא נותן להוסיף עם השגיאה הנ"ל.
הקובץ השני מוסיף את זה:
-
@דאנציג
מצויין כמו שאמרתי ה- frx לא אמור להיות מותקן הוא רק קובץ תומך@pcinfogmach והיכן הוא אמור להיות?
בSTARTUP, או בTemplates?
אגב, זה בדיוק הקובץ של הקטנת והגדלת סוגריים של ניקיוזר, אך אם אני לא נותן לו את פקודת המאקרו, כיצד הוא יפעל? -
@pcinfogmach והיכן הוא אמור להיות?
בSTARTUP, או בTemplates?
אגב, זה בדיוק הקובץ של הקטנת והגדלת סוגריים של ניקיוזר, אך אם אני לא נותן לו את פקודת המאקרו, כיצד הוא יפעל?@דאנציג כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
@pcinfogmach והיכן הוא אמור להיות?
בSTARTUP, או בTemplates?אם אתה רוצה שיאתחל עם וורד אז בstartup או פשוט תוסיף אותו לתבנית נורמל.
אגב, זה בדיוק הקובץ של הקטנת והגדלת סוגריים של ניקיוזר,
זה דומה אבל לא בדיוק השמטתי חלק מהאפשרויות והוספתי פונקציות ועשיתי קוד חדש, יותר פשוט ונקי.
אך אם אני לא נותן לו את פקודת המאקרו, כיצד הוא יפעל?
צודק
היה עוד בעיה שתוקנה עכשיו עם השם של היוזרפורםולהוסיף בתוך מודול רגיל קוד כזה
Sub Parenthesis() MyParenthesis.Show End Sub
-
הגדל והקטן רווחים בין מילים בפיסקאות שנבחרו
עריכה: הקוד שופץ ונערך מחדש על פי ההצעה של @מאקרו
עריכה2: הקוד שימושי ליישור טורים ,אם חסר שורה בין הטורים אפשר כך להוסיף שורה בלי שיורגש...Option Explicit Sub הגדל_רווחים_בין_מילים() Dim rng, para, spaceRange As Range, i As Integer Set rng = Selection.Range 'loop throgh pragraphs For i = 1 To rng.Paragraphs.Count Set para = rng.Paragraphs(i).Range Set spaceRange = para.Duplicate ' Loop through each space in the selected paragraph Do While spaceRange.InRange(para) spaceRange.MoveStartUntil " " ' Move to the next space If spaceRange.InRange(para) Then _ spaceRange.Characters(1).Font.Spacing = spaceRange.Characters(1).Font.Spacing + 1 spaceRange.MoveStart unit:=wdCharacter, Count:=1 ' Move to the next character Loop Next i End Sub Sub הקטן_רווחים_בין_מילים() Dim rng, para, spaceRange As Range, i As Integer Set rng = Selection.Range 'loop throgh pragraphs For i = 1 To rng.Paragraphs.Count Set para = rng.Paragraphs(i).Range Set spaceRange = para.Duplicate ' Loop through each space in the selected paragraph Do While spaceRange.InRange(para) spaceRange.MoveStartUntil " " ' Move to the next space If spaceRange.InRange(para) Then _ spaceRange.Characters(1).Font.Spacing = spaceRange.Characters(1).Font.Spacing - 1 spaceRange.MoveStart unit:=wdCharacter, Count:=1 ' Move to the next character Loop Next i End Sub
עריכה 3:
והנה קוד בשיטה אחרת לפי ההצעה של @menajemmendel קוד זה נערך על ידי ושופץ בעזרת @מאקרוSub ChangeSpacing() Dim myrange As Range, orange As Range Set myrange = Selection.Range myrange.SetRange Selection.Paragraphs.First.Range.Start, Selection.Paragraphs.Last.Range.End Set orange = ActiveDocument.Range(myrange.Start, myrange.End) With orange .Collapse .MoveUntil cset:=" " .SetRange Start:=.Start, End:=.Start + 1 .Select End With Dim c As Font, rslt As Integer Set c = Selection.Font rslt = c.Spacing + 1 With myrange.Find .ClearFormatting .Replacement.ClearFormatting .Replacement.Font.Spacing = rslt .Text = " " .Replacement.Text = "^&" .Forward = False .Wrap = wdFindStop .Format = True End With myrange.Find.Execute Replace:=wdReplaceAll End Sub
-
הסרת כל הרווחים בטקסט שסומן
Sub DeleteSpacesInParagraph() Dim rng As Range ' Set the range to the current paragraph Set rng = Selection.Range ' Remove all spaces rng.text = Replace(rng.text, " ", "") End Sub
-
הגדל והקטן רווחים בין מילים בפיסקאות שנבחרו
עריכה: הקוד שופץ ונערך מחדש על פי ההצעה של @מאקרו
עריכה2: הקוד שימושי ליישור טורים ,אם חסר שורה בין הטורים אפשר כך להוסיף שורה בלי שיורגש...Option Explicit Sub הגדל_רווחים_בין_מילים() Dim rng, para, spaceRange As Range, i As Integer Set rng = Selection.Range 'loop throgh pragraphs For i = 1 To rng.Paragraphs.Count Set para = rng.Paragraphs(i).Range Set spaceRange = para.Duplicate ' Loop through each space in the selected paragraph Do While spaceRange.InRange(para) spaceRange.MoveStartUntil " " ' Move to the next space If spaceRange.InRange(para) Then _ spaceRange.Characters(1).Font.Spacing = spaceRange.Characters(1).Font.Spacing + 1 spaceRange.MoveStart unit:=wdCharacter, Count:=1 ' Move to the next character Loop Next i End Sub Sub הקטן_רווחים_בין_מילים() Dim rng, para, spaceRange As Range, i As Integer Set rng = Selection.Range 'loop throgh pragraphs For i = 1 To rng.Paragraphs.Count Set para = rng.Paragraphs(i).Range Set spaceRange = para.Duplicate ' Loop through each space in the selected paragraph Do While spaceRange.InRange(para) spaceRange.MoveStartUntil " " ' Move to the next space If spaceRange.InRange(para) Then _ spaceRange.Characters(1).Font.Spacing = spaceRange.Characters(1).Font.Spacing - 1 spaceRange.MoveStart unit:=wdCharacter, Count:=1 ' Move to the next character Loop Next i End Sub
עריכה 3:
והנה קוד בשיטה אחרת לפי ההצעה של @menajemmendel קוד זה נערך על ידי ושופץ בעזרת @מאקרוSub ChangeSpacing() Dim myrange As Range, orange As Range Set myrange = Selection.Range myrange.SetRange Selection.Paragraphs.First.Range.Start, Selection.Paragraphs.Last.Range.End Set orange = ActiveDocument.Range(myrange.Start, myrange.End) With orange .Collapse .MoveUntil cset:=" " .SetRange Start:=.Start, End:=.Start + 1 .Select End With Dim c As Font, rslt As Integer Set c = Selection.Font rslt = c.Spacing + 1 With myrange.Find .ClearFormatting .Replacement.ClearFormatting .Replacement.Font.Spacing = rslt .Text = " " .Replacement.Text = "^&" .Forward = False .Wrap = wdFindStop .Format = True End With myrange.Find.Execute Replace:=wdReplaceAll End Sub
@pcinfogmach למה בלופ, מה רע לך בחפש והחלף? וכי הוא לא יותר מהיר?
-
@pcinfogmach למה בלופ, מה רע לך בחפש והחלף? וכי הוא לא יותר מהיר?
@menajemmendel
חפש והחלף אכן יותר מהיר ויעיל
היה לי 2 בעיות עם חפש והחלף אחד מהם @מאקרו עזר לי לפתור כך שאין צורך להעלות כאן כרגע
השני עדיין עומד, שעל ידי חפש והחלף אם יש רווחים עם גדלים שונים במקטע אז זה ידרוס אותם ויעשה הכל רווחים אחידים אשמח לשמוע אם יש לך פיתרון לזה -
@menajemmendel
חפש והחלף אכן יותר מהיר ויעיל
היה לי 2 בעיות עם חפש והחלף אחד מהם @מאקרו עזר לי לפתור כך שאין צורך להעלות כאן כרגע
השני עדיין עומד, שעל ידי חפש והחלף אם יש רווחים עם גדלים שונים במקטע אז זה ידרוס אותם ויעשה הכל רווחים אחידים אשמח לשמוע אם יש לך פיתרון לזה@pcinfogmach תעשה חפש את הבא במקום החלף הכל, וכשנמצא רווח תגדיל אותו באופן פרטני.
-
@pcinfogmach למה בלופ, מה רע לך בחפש והחלף? וכי הוא לא יותר מהיר?
@menajemmendel כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
@pcinfogmach למה בלופ, מה רע לך בחפש והחלף? וכי הוא לא יותר מהיר?
ניסית בחפש והחלף אבל לבינתיים אני לא מצליח שיעשה החלפה רק בפסקאות שסומנו. (השיטה הרגילה שלי לחיפוש במיקום מסויים עובדת רק בלי בחירת עיצוב).
-
@menajemmendel כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
@pcinfogmach למה בלופ, מה רע לך בחפש והחלף? וכי הוא לא יותר מהיר?
ניסית בחפש והחלף אבל לבינתיים אני לא מצליח שיעשה החלפה רק בפסקאות שסומנו. (השיטה הרגילה שלי לחיפוש במיקום מסויים עובדת רק בלי בחירת עיצוב).
@pcinfogmach כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
@menajemmendel כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
@pcinfogmach למה בלופ, מה רע לך בחפש והחלף? וכי הוא לא יותר מהיר?
ניסית בחפש והחלף אבל לבינתיים אני לא מצליח שיעשה החלפה רק בפסקאות שסומנו. (השיטה הרגילה שלי לחיפוש במיקום מסויים עובדת רק בלי בחירת עיצוב).
מה אתה מתכוןן? קודם מגדירים שההבחירה יהיה RANGE ואחר כן
במקוםSelection.Find
עושים
myrange.Find
ואז אתה יכול לחפש מה שאתה רוצה כרגיל,
-
@pcinfogmach כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
@menajemmendel כתב בשיתוף | אינצקלופדיה שיתופית עבור קודים של מאקרו - איך עושים את....:
@pcinfogmach למה בלופ, מה רע לך בחפש והחלף? וכי הוא לא יותר מהיר?
ניסית בחפש והחלף אבל לבינתיים אני לא מצליח שיעשה החלפה רק בפסקאות שסומנו. (השיטה הרגילה שלי לחיפוש במיקום מסויים עובדת רק בלי בחירת עיצוב).
מה אתה מתכוןן? קודם מגדירים שההבחירה יהיה RANGE ואחר כן
במקוםSelection.Find
עושים
myrange.Find
ואז אתה יכול לחפש מה שאתה רוצה כרגיל,
פוסט זה נמחק! -
איך ליצור range נפרד עבור כל טור בהערות שוליים
המאקרו לא עושה כלום כרגע רק קובע range נפרד עבור כל טור כדי לאפשר לעשות עליהם פעולות
המאקרו בנוי בשביל לרוץ על העמוד הנוכחי כדי להריץ על כל המסמך יש ליצור לולאה שתרוץ על כל העמודים במסמך.Sub טורים() 'נתוני עמוד Dim currpagenum, pg2num As Long Dim currPageRange As Range If ActiveWindow.View.SeekView = wdSeekFootnotes Then ActiveWindow.View.SeekView = wdSeekMainDocument currpagenum = Selection.Information(wdActiveEndPageNumber) Set currPageRange = ActiveDocument.Bookmarks("\page").Range 'נתוני הערות שוליים Dim ftnoteclmn1 As Range Dim ftnoteclmn2 As Range Dim i As Integer, lastftnote As Integer Dim ftnote As footnote 'הגדר את תחילת הטור הראשון בהערות שוליים ActiveWindow.View.SeekView = wdSeekFootnotes Set ftnoteclmn1 = Selection.Range 'מצא את המעבר בין הטורים על ידי לולאה lastftnote = currPageRange.Footnotes.Count For i = 1 To lastftnote Set ftnote = currPageRange.Footnotes(i) If ftnote.Range.Information(wdHorizontalPositionRelativeToPage) < ActiveDocument.PageSetup.pageWidth / 2 Then ftnote.Range.Select Selection.HomeKey Unit:=wdLine Do While Selection.Information(wdHorizontalPositionRelativeToPage) < ActiveDocument.PageSetup.pageWidth / 2 Selection.MoveLeft Unit:=wdWord, Count:=1 Loop Selection.MoveRight Unit:=wdWord, Count:=1 Exit For End If Next 'הגדר את סוף הטור הראשון ftnoteclmn1.End = Selection.Range.Start 'הגדר את תחילת הטור השני Set ftnoteclmn2 = Selection.Range 'מצא את סוף העמוד currPageRange.Footnotes(lastftnote).Range.Select Selection.EndKey Unit:=wdLine pg2num = Selection.Information(wdActiveEndPageNumber) Do While pg2num <> currpagenum Selection.MoveLeft Unit:=wdWord, Count:=1 pg2num = Selection.Range.Information(wdActiveEndPageNumber) Loop 'Selection.MoveRight Unit:=wdWord, Count:=1 'הגדר את סוף הטור השני ftnoteclmn2.End = Selection.Range.Start End Sub