עזרה בוורד עזרה בהכנסת שאילה במאקרו

הללוהו ב ו

משתמש מקצוען
פעולה 1 A=nz(MsgBox("שאלה?", vbQuestion + vbYesNoCancel + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת"),0) if A=vbyes then פעולה 2
הוא כותב לי שגיאה במילים אלו : (במקום שכתוב פקודה 1 ו2 האם למחוק לגמרי מילים אלו?)
1626430434762.png
 

אפר

סתם מתעניין...
מנוי פרימיום
רק המילים בעברית או בתוספת הקידומת והסוגריים ()?
והאם צריך להוסיף "מרכאות" לפני"ז או משהו?
יש שם בדרך כלל השם האוטומטי הוא Macro+מספר
ניתן להחליף לכל מילה אחרת באנגליתללא רווחים טת השם הנ"ל
לאחר מכן ניתן להשתמש בזה לקרוא למאקרו ללא שום תוספות
 

הללוהו ב ו

משתמש מקצוען
מה שכתוב שם
אכניס דוגמא של מה שעשיתי ותודיע לי מה לא טוב: זה רק דוגמא של ב' מיני מאקרוים..
קוד:
Sub Macro1()
'
' Macro1 Macro
'

Dim A As Long
Again:
start:
With Selection.Find
    .ClearFormatting
    .Execute findText:="[0-9]{1,}", MatchWildcards:=True, Format:=False, Wrap:=wdFindContinue
    If .Found = True Then
S = ""

MyArray = Array(400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
MyaArray = Array("ת", "ש", "ר", "ק", "צ", "פ", "ע", "ס", "נ", "מ", "ל", "כ", _
"י", "ט", "ח", "ז", "ו", "ה", "ד", "ג", "ב", "א")
V = Val(Selection)
Do While V > 0
If V = 15 Or V = 16 Then
S = S & "ט"
V = V - 9
End If
  For i = 0 To UBound(MyArray)
    If V >= MyArray(i) Then
      S = S & MyaArray(i)
      V = V - MyArray(i)
      Exit For
    End If
  Next i
Loop

If S = "רצח" Then S = "רחצ"
If S = "רע" Then S = "ער"
If S = "רעב" Then S = "ערב"
If S = "שד" Then S = "דש"
If S = "שמד" Then S = "שדמ"
If S = "תשמד" Then S = "תדשם"
If S = "רעד" Then S = "רדע"

If Len(S) = 1 Then
    S = S & "'"
Else
    S = Left(S, (Len(S) - 1)) & Chr(34) & Right(S, 1)
End If

Selection = S

GoTo start
    End If
End With

A = nz(MsgBox("שאלה?", vbQuestion + vbYesNoCancel + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת"), 0)
If A = vbYes Then
  
arrFind = Array("בראשית", "שמות", "ויקרא", "במדבר", "דברים")

For f = 0 To UBound(arrFind)
    Selection.Find.Text = "{" & arrFind(f) & "}"
    Selection.Find.Replacement.Text = "(" & arrFind(f) & ")"
    Selection.Find.Wrap = wdFindContinue
    Selection.Find.Execute Replace:=wdReplaceAll
Next

    If MsgBox("לחזור שוב?", vbQuestion + vbYesNo + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת") = vbYes Then GoTo Again
ElseIf A = vbNo Then
    MsgBox "לא נמצאה פעולה מתאימה", vbCritical + vbMsgBoxRight + vbMsgBoxRtlReading, "שגיאה"
ElseIf A = vbCancel Then
    Exit Sub
Else

   End If
End Sub
 

אפר

סתם מתעניין...
מנוי פרימיום
אכניס דוגמא של מה שעשיתי ותודיע לי מה לא טוב: זה רק דוגמא של ב' מיני מאקרוים..
קוד:
Sub Macro1()
'
' Macro1 Macro
'

Dim A As Long
Again:
start:
With Selection.Find
    .ClearFormatting
    .Execute findText:="[0-9]{1,}", MatchWildcards:=True, Format:=False, Wrap:=wdFindContinue
    If .Found = True Then
S = ""

MyArray = Array(400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
MyaArray = Array("ת", "ש", "ר", "ק", "צ", "פ", "ע", "ס", "נ", "מ", "ל", "כ", _
"י", "ט", "ח", "ז", "ו", "ה", "ד", "ג", "ב", "א")
V = Val(Selection)
Do While V > 0
If V = 15 Or V = 16 Then
S = S & "ט"
V = V - 9
End If
  For i = 0 To UBound(MyArray)
    If V >= MyArray(i) Then
      S = S & MyaArray(i)
      V = V - MyArray(i)
      Exit For
    End If
  Next i
Loop

If S = "רצח" Then S = "רחצ"
If S = "רע" Then S = "ער"
If S = "רעב" Then S = "ערב"
If S = "שד" Then S = "דש"
If S = "שמד" Then S = "שדמ"
If S = "תשמד" Then S = "תדשם"
If S = "רעד" Then S = "רדע"

If Len(S) = 1 Then
    S = S & "'"
Else
    S = Left(S, (Len(S) - 1)) & Chr(34) & Right(S, 1)
End If

Selection = S

GoTo start
    End If
End With

A = nz(MsgBox("שאלה?", vbQuestion + vbYesNoCancel + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת"), 0)
If A = vbYes Then
 
arrFind = Array("בראשית", "שמות", "ויקרא", "במדבר", "דברים")

For f = 0 To UBound(arrFind)
    Selection.Find.Text = "{" & arrFind(f) & "}"
    Selection.Find.Replacement.Text = "(" & arrFind(f) & ")"
    Selection.Find.Wrap = wdFindContinue
    Selection.Find.Execute Replace:=wdReplaceAll
Next

    If MsgBox("לחזור שוב?", vbQuestion + vbYesNo + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת") = vbYes Then GoTo Again
ElseIf A = vbNo Then
    MsgBox "לא נמצאה פעולה מתאימה", vbCritical + vbMsgBoxRight + vbMsgBoxRtlReading, "שגיאה"
ElseIf A = vbCancel Then
    Exit Sub
Else

   End If
End Sub
הכנסת ללופ אינסופי עם ה GOTO START
 

אפר

סתם מתעניין...
מנוי פרימיום
אני לא מבין?
אתה יכול להראות לי באיזה שורות להחליף במה?
תודה רבה!
הSTART חוזר כל הזמן עד מתי?
ותעלה לי צילום מסך כשהוא נתקע מה כתוב ועל איזה שורה הוא נתקע
 

אפר

סתם מתעניין...
מנוי פרימיום
הראיתי שם תמונות מסך: אותו שורה גם קופצת כשהורדתי את המספר 2.

צפה בקובץ המצורף 933654
תחליף את
קוד:
A = nz(MsgBox("שאלה?", vbQuestion + vbYesNoCancel + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת"), 0)
ב
קוד:
A = MsgBox("שאלה?", vbQuestion + vbYesNoCancel + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת")

וזה
קוד:
Dim A as long
בזה
קוד:
Dim A
 

הללוהו ב ו

משתמש מקצוען
תודה רבה על כל העזרה מא ועד ת אשמח לשמוע בהמשך עוד וכן אם תוכל לתקן ולבדוק בשאר הדברים תודה רבה
אני אבדוק את מה ששלחת לי שבוע הבא בעזהשי"ת תודה ושבת שלום!!
 

הללוהו ב ו

משתמש מקצוען
שמתי לב עכשיו שבהנ"ל ששלחתי לי עם ההגהות שתיקנת כפי שרשום פה למשל ברעיון הנ"ל של החלפה ממספור לאותיות גם אם התשובה שלי תהיה "לא" הוא יבצע את הפעולה ! אם תוכל לבדוק למה ומה אני אמור לתקן... ?
 

אפר

סתם מתעניין...
מנוי פרימיום
שמתי לב עכשיו שבהנ"ל ששלחתי לי עם ההגהות שתיקנת כפי שרשום פה למשל ברעיון הנ"ל של החלפה ממספור לאותיות גם אם התשובה שלי תהיה "לא" הוא יבצע את הפעולה ! אם תוכל לבדוק למה ומה אני אמור לתקן... ?
לא מצליח להבין את כוונתך
צרף את הקטע הרלוונטי
 

הללוהו ב ו

משתמש מקצוען
צרף את הקטע הרלוונטי
הנה , הכנסתי שתי פקודות וגם כשאני לוחץ על "לא" כל זמן שאני לא לוחץ על ביטול הוא עושה את הפעולה:
קוד:
Sub אראה()
'
' Macro1 Macro
'

Dim A
Again:
start:
With Selection.Find
    .ClearFormatting
    .Execute findText:="[0-9]{1,}", MatchWildcards:=True, Format:=False, Wrap:=wdFindContinue
    If .Found = True Then
S = ""

MyArray = Array(400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
MyaArray = Array("ת", "ש", "ר", "ק", "צ", "פ", "ע", "ס", "נ", "מ", "ל", "כ", _
"י", "ט", "ח", "ז", "ו", "ה", "ד", "ג", "ב", "א")
V = Val(Selection)
Do While V > 0
If V = 15 Or V = 16 Then
S = S & "ט"
V = V - 9
End If
  For i = 0 To UBound(MyArray)
    If V >= MyArray(i) Then
      S = S & MyaArray(i)
      V = V - MyArray(i)
      Exit For
    End If
  Next i
Loop

If S = "רצח" Then S = "רחצ"
If S = "רע" Then S = "ער"
If S = "רעב" Then S = "ערב"
If S = "שד" Then S = "דש"
If S = "שמד" Then S = "שדמ"
If S = "תשמד" Then S = "תדשם"
If S = "רעד" Then S = "רדע"

If Len(S) = 1 Then
    S = S & "'"
Else
    S = Left(S, (Len(S) - 1)) & Chr(34) & Right(S, 1)
End If

Selection = S

GoTo start
    End If
End With

A = MsgBox("שאלה?", vbQuestion + vbYesNoCancel + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת")

If A = vbYes Then
 
 Dim TextFind As String
    TextFind = "" & InputBox("הוספת ~", "הזן את המילה להחלפה")
    If TextFind = "" Then Exit Sub
    Application.DisplayAlerts = wdAlertsNone
    With Selection.Find
        .Text = TextFind
        .Replacement.Text = "~ " & TextFind
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Application.DisplayAlerts = wdAlertsAll

    If MsgBox("לחזור שוב?", vbQuestion + vbYesNo + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת") = vbYes Then GoTo Again
ElseIf A = vbNo Then
    MsgBox "לא נמצאה פעולה מתאימה", vbCritical + vbMsgBoxRight + vbMsgBoxRtlReading, "שגיאה"
ElseIf A = vbCancel Then
    Exit Sub
Else

   End If
End Sub
בשאילה הראשונה.
 

אפר

סתם מתעניין...
מנוי פרימיום
הנה , הכנסתי שתי פקודות וגם כשאני לוחץ על "לא" כל זמן שאני לא לוחץ על ביטול הוא עושה את הפעולה:
קוד:
Sub אראה()
'
' Macro1 Macro
'

Dim A
Again:
start:
With Selection.Find
    .ClearFormatting
    .Execute findText:="[0-9]{1,}", MatchWildcards:=True, Format:=False, Wrap:=wdFindContinue
    If .Found = True Then
S = ""

MyArray = Array(400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
MyaArray = Array("ת", "ש", "ר", "ק", "צ", "פ", "ע", "ס", "נ", "מ", "ל", "כ", _
"י", "ט", "ח", "ז", "ו", "ה", "ד", "ג", "ב", "א")
V = Val(Selection)
Do While V > 0
If V = 15 Or V = 16 Then
S = S & "ט"
V = V - 9
End If
  For i = 0 To UBound(MyArray)
    If V >= MyArray(i) Then
      S = S & MyaArray(i)
      V = V - MyArray(i)
      Exit For
    End If
  Next i
Loop

If S = "רצח" Then S = "רחצ"
If S = "רע" Then S = "ער"
If S = "רעב" Then S = "ערב"
If S = "שד" Then S = "דש"
If S = "שמד" Then S = "שדמ"
If S = "תשמד" Then S = "תדשם"
If S = "רעד" Then S = "רדע"

If Len(S) = 1 Then
    S = S & "'"
Else
    S = Left(S, (Len(S) - 1)) & Chr(34) & Right(S, 1)
End If

Selection = S

GoTo start
    End If
End With

A = MsgBox("שאלה?", vbQuestion + vbYesNoCancel + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת")

If A = vbYes Then

Dim TextFind As String
    TextFind = "" & InputBox("הוספת ~", "הזן את המילה להחלפה")
    If TextFind = "" Then Exit Sub
    Application.DisplayAlerts = wdAlertsNone
    With Selection.Find
        .Text = TextFind
        .Replacement.Text = "~ " & TextFind
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Application.DisplayAlerts = wdAlertsAll

    If MsgBox("לחזור שוב?", vbQuestion + vbYesNo + vbMsgBoxRight + vbMsgBoxRtlReading, "כותרת") = vbYes Then GoTo Again
ElseIf A = vbNo Then
    MsgBox "לא נמצאה פעולה מתאימה", vbCritical + vbMsgBoxRight + vbMsgBoxRtlReading, "שגיאה"
ElseIf A = vbCancel Then
    Exit Sub
Else

   End If
End Sub
בשאילה הראשונה.
אצלי עובד מעולה
לחצתי לא והוא עובר ללא נמצאה פעולה מתאימה
 

אולי מעניין אותך גם...

הפרק היומי

הפרק היומי! כל ערב פרק תהילים חדש. הצטרפו אלינו לקריאת תהילים משותפת!


תהילים פרק קכא

א שִׁיר לַמַּעֲלוֹת אֶשָּׂא עֵינַי אֶל הֶהָרִים מֵאַיִן יָבֹא עֶזְרִי:ב עֶזְרִי מֵעִם יְהוָה עֹשֵׂה שָׁמַיִם וָאָרֶץ:ג אַל יִתֵּן לַמּוֹט רַגְלֶךָ אַל יָנוּם שֹׁמְרֶךָ:ד הִנֵּה לֹא יָנוּם וְלֹא יִישָׁן שׁוֹמֵר יִשְׂרָאֵל:ה יְהוָה שֹׁמְרֶךָ יְהוָה צִלְּךָ עַל יַד יְמִינֶךָ:ו יוֹמָם הַשֶּׁמֶשׁ לֹא יַכֶּכָּה וְיָרֵחַ בַּלָּיְלָה:ז יְהוָה יִשְׁמָרְךָ מִכָּל רָע יִשְׁמֹר אֶת נַפְשֶׁךָ:ח יְהוָה יִשְׁמָר צֵאתְךָ וּבוֹאֶךָ מֵעַתָּה וְעַד עוֹלָם:
נקרא  16  פעמים

לוח מודעות

למעלה