יש פעמים שבאים לערוך קובץ באוצרייא ולעשות לו קידוד למשל
חבורה בענין וכו'
וככה זה רץ על כל הספר
יש קוד שביקשתי מהצ'אט שיעזור לי בכתיבה שלו בשביל שיעזור למצא את כל המילים שאני אבחר ואפשר כמה כאלה ואפשר כמה רמות של כותרת עד 9 רמות
וככה אפשר לקודד ספר בכמה דקות
Function GetHebrewDateTime() As String
Dim hDate As String
hDate = Format(Date, "Long Date", vbHebrew)
Dim hTime As String
hTime = Format(Time, "hh_mm")
GetHebrewDateTime = Replace(hDate, "יום ", "") & " " & hTime
End Function
Sub MultiHeadingTagReplacerWithAutoOpenLog()
Dim searchWords() As String
Dim headingLevels() As Integer
Dim replacements() As Integer
Dim i As Integer, count As Integer
Dim wordInput As String, headingInput As String
count = 0
Do
wordInput = InputBox("הזן מילה שמתחילה שורה (או השאר ריק לסיום):", "החלפה #" & count + 1)
If wordInput = "" Then Exit Do
headingInput = InputBox("הזן מספר כותרת מתאים (1-9) עבור """ & wordInput & """:", "כותרת למילה #" & count + 1)
If Not IsNumeric(headingInput) Or Val(headingInput) < 1 Or Val(headingInput) > 9 Then
MsgBox "מספר כותרת לא חוקי. נסה שוב."
Exit Sub
End If
count = count + 1
ReDim Preserve searchWords(1 To count)
ReDim Preserve headingLevels(1 To count)
ReDim Preserve replacements(1 To count)
searchWords(count) = wordInput
headingLevels(count) = CInt(headingInput)
replacements(count) = 0
Loop
If count = 0 Then
MsgBox "לא הוזנה אף מילה.", vbExclamation
Exit Sub
End If
Dim para As Paragraph
For Each para In ActiveDocument.Paragraphs
Dim lineText As String
lineText = Trim(para.Range.Text)
If Right(lineText, 1) = vbCr Then
lineText = Left(lineText, Len(lineText) - 1)
End If
For i = 1 To count
If Left(lineText, Len(searchWords(i))) = searchWords(i) Then
If InStr(lineText, vbCr) = 0 Then
Dim tagOpen As String, tagClose As String
tagOpen = "<h" & headingLevels(i) & ">"
tagClose = "</h" & headingLevels(i) & ">"
para.Range.Text = tagOpen & lineText & tagClose & vbCr
replacements(i) = replacements(i) + 1
Else
para.Range.Font.Color = wdColorRed
End If
Exit For
End If
Next i
Next para
Dim createLog As VbMsgBoxResult
createLog = MsgBox("האם ברצונך ליצור ולפתוח קובץ סיכום עם תאריך עברי ושעה?", vbYesNo + vbQuestion, "קובץ סיכום")
If createLog = vbYes Then
Dim docName As String
docName = Left(ActiveDocument.Name, InStrRev(ActiveDocument.Name, ".") - 1)
Dim hebDateTime As String
hebDateTime = GetHebrewDateTime()
hebDateTime = Replace(hebDateTime, " ", "_")
Dim logFileName As String
logFileName = "מידע קובץ " & docName & " " & hebDateTime & ".txt"
Dim logFilePath As String
logFilePath = ActiveDocument.Path & "\" & logFileName
Dim fso As Object, logfile As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set logfile = fso.CreateTextFile(logFilePath, True)
logfile.WriteLine "דו״ח החלפות עבור """ & docName & """"
logfile.WriteLine "תאריך עברי: " & Replace(GetHebrewDateTime(), "_", " ")
logfile.WriteLine String(50, "-")
For i = 1 To count
logfile.WriteLine "מילה: " & searchWords(i) & _
" → תג: <h" & headingLevels(i) & ">" & _
" | הוחלפה " & replacements(i) & " פעמים"
Next i
logfile.Close
Shell "notepad.exe """ & logFilePath & """", vbNormalFocus
End If
End Sub
@יום-חדש-מתחיל