Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Paste Description for olecom

msword is inserting phpbb post tags for you

olecom
Sunday, September 5th, 2010 at 5:41:59pm MDT 

  1. ==
  2. == File of "Microsoft Word Objects" aka ThisDocument: Форум_GallopeRU_v001.cls ==
  3. ==
  4. VERSION 1.0 CLASS
  5. BEGIN
  6.   MultiUse = -1  'True
  7. END
  8. Attribute VB_Name = "Форум_GallopeRU_v001"
  9. Attribute VB_GlobalNameSpace = False
  10. Attribute VB_Creatable = False
  11. Attribute VB_PredeclaredId = True
  12. Attribute VB_Exposed = True
  13. ' _v001 -- 1) поддержка текстованных urlов; они синие и подчёркиваются (порядок тэгов для форума важен)
  14. '          2) убрал маленький шрифт для форумтэгов (нафига, когда они undoца)
  15.  
  16. ' подключаемся к событиям окон, для ловли выделения (больше ничего Word не может предложить)
  17. Dim События As New Класс_Событий
  18. Sub Document_Open()
  19. Set События.прога = Word.Application
  20. End Sub
  21.  
  22. ==
  23. == File of "Class Modules": Класс_Событий.cls ==
  24. ==
  25.  
  26. VERSION 1.0 CLASS
  27. BEGIN
  28.   MultiUse = -1  'True
  29. END
  30. Attribute VB_Name = "Класс_Событий"
  31. Attribute VB_GlobalNameSpace = False
  32. Attribute VB_Creatable = False
  33. Attribute VB_PredeclaredId = False
  34. Attribute VB_Exposed = False
  35. Public WithEvents прога As Word.Application
  36. Attribute прога.VB_VarHelpID = -1
  37. Sub прога_WindowSelectionChange(ByVal Sel As Selection)
  38. Dim i, j, s, d, возврат, имя
  39.  
  40. If Len(Sel.Range.Document.Content.Text) = Len(Sel.Text) Then
  41.     параментры_поста.Show
  42.     If параментры_поста.Tag <> "АГА" Then
  43.         Exit Sub
  44.     End If
  45.     If Right(параментры_поста.адрес, 1) <> "/" Then
  46.         параментры_поста.адрес = параментры_поста.адрес & "/"
  47.     End If
  48.  
  49.     ActiveDocument.Save
  50.     имя = ActiveDocument.Path + "\" + ActiveDocument.Name
  51.     d = ActiveDocument.Path + "\" + "Картинки-" & ActiveDocument.Name
  52.     Set fs = CreateObject("Scripting.FileSystemObject")
  53.     On Error Resume Next ' вЫрубаем ошибки
  54.     fs.DeleteFolder ActiveDocument.Path + "\" + d + ".files"
  55.     On Error GoTo 0 ' врубаем ошибки
  56.    
  57.     ActiveDocument.SaveAs FileName:=d + ".htm", FileFormat:=wdFormatFilteredHTML, AddToRecentFiles:=False
  58.    
  59.     возврат = 0
  60.     ' жирный
  61.     Sel.HomeKey Unit:=wdStory
  62.     With Sel.Find
  63.         .ClearFormatting
  64.         .Font.Bold = True
  65.        
  66.         Do While .Execute(FindText:="", Forward:=True, Format:=True, Wrap:=wdFindStop) = True
  67.             i = Len(Sel.Text)
  68.             With .Parent
  69.                 .InsertBefore "[b]"
  70.                 .InsertAfter "[/b]"
  71.             End With
  72.             Selection.MoveRight Unit:=wdCharacter, Count:=1
  73.             возврат = возврат + 2
  74.         Loop
  75.     End With
  76.  
  77.     ' курсив
  78.     Sel.HomeKey Unit:=wdStory
  79.     With Sel.Find
  80.         .ClearFormatting
  81.         .Font.Italic = True
  82.         Do While .Execute(FindText:="", Forward:=True, Format:=True, Wrap:=wdFindStop) = True
  83.             i = Len(Sel.Text)
  84.             With .Parent
  85.                 .InsertBefore "[i]"
  86.                 .InsertAfter "[/i]"
  87.             End With
  88.             Selection.MoveRight Unit:=wdCharacter, Count:=1
  89.             возврат = возврат + 2
  90.         Loop
  91.     End With
  92.  
  93.     ' подчёркнутый
  94.     Sel.HomeKey Unit:=wdStory
  95.     With Sel.Find
  96.         .ClearFormatting
  97.         .Font.Underline = wdUnderlineSingle
  98.         Do While .Execute(FindText:="", Forward:=True, Format:=True, Wrap:=wdFindStop) = True
  99.             i = Len(Sel.Text)
  100.             With .Parent
  101.                 .InsertBefore "[u]"
  102.                 .InsertAfter "[/u]"
  103.             End With
  104.             Selection.MoveRight Unit:=wdCharacter, Count:=1
  105.             возврат = возврат + 2
  106.         Loop
  107.     End With
  108.    
  109.     ' картинки
  110.     i = 0
  111.     j = Dir(d + ".files\image*.*")
  112.     For Each картинка In ActiveDocument.InlineShapes
  113.     Dim f
  114.         s = Right(j, 4)
  115.         If картинка.AlternativeText = "" Then
  116.         ' формируем туповатое имя и расширение
  117. f = параментры_поста.имя + VBA.CStr(i) + s
  118. s = vbCrLf + "[img]" + параментры_поста.адрес + f + "[/img]"
  119.         Else
  120.         ' альтернативный текст -- это имя файла картинки, и оно должно быть похоже на имя для Винды
  121. f = VBA.Replace(VBA.Replace(картинка.AlternativeText, " ", "_"), ":", "")
  122. f = VBA.Replace(VBA.Replace(VBA.Replace(VBA.Replace(f, "\", ""), "/", ""), "?", ""), "*", "")
  123. f = VBA.Replace(VBA.Replace(VBA.Replace(VBA.Replace(f, "<", ""), ">", ""), "|", ""), Chr(34), "")
  124. f = параментры_поста.имя + f + s
  125.         ' к префиксу добавляем имя и расширение
  126. s = vbCrLf + "[img]" + параментры_поста.адрес + f + "[/img]"
  127.         End If
  128.         On Error Resume Next ' вЫрубаем ошибки
  129.         fs.DeleteFile d + ".files\" + f ' убираем, возможно уже имеющийся файл
  130.         fs.MoveFile d + ".files\" + j, d + ".files\" + f ' переименовываем
  131.         On Error GoTo 0 ' врубаем ошибки
  132.  
  133.         картинка.Range.InsertAfter s
  134.         j = Dir
  135.         i = i + 1
  136.         возврат = возврат + 1
  137.     Next
  138.    
  139.     ' линки
  140.     For Each h In ActiveDocument.Hyperlinks
  141.         With h.Range
  142.             .InsertBefore "[url=" + h.Address + "#" + h.SubAddress + "][color=#0000FF]"
  143.             .InsertAfter "[/color][/url]"
  144.         End With
  145.         возврат = возврат + 2
  146.     Next
  147.    
  148.     ' завершение работы
  149.     Selection.WholeStory
  150.     Selection.Copy
  151.     ActiveDocument.Undo возврат
  152.     ActiveDocument.SaveAs имя, wdFormatDocument
  153.     Sel.EndKey Unit:=wdStory
  154.     ActiveWindow.View.Type = wdNormalView
  155.  
  156.     fs.DeleteFile d + ".htm"
  157.     ChDir ActiveDocument.Path
  158. End If
  159. End Sub
  160.  
  161. ==
  162. == File of "Forms": параментры_поста.frm ==
  163. ==
  164. VERSION 5.00
  165. Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} параментры_поста
  166.    Caption         =   "Преобразование текста для форума Galloper.ru (движок phpBB)"
  167.    ClientHeight    =   3300
  168.    ClientLeft      =   45
  169.    ClientTop       =   330
  170.    ClientWidth     =   11055
  171.    OleObjectBlob   =   "параментры_поста.frx":0000
  172.    StartUpPosition =   1  'CenterOwner
  173.    Tag             =   "0"
  174. End
  175. Attribute VB_Name = "параментры_поста"
  176. Attribute VB_GlobalNameSpace = False
  177. Attribute VB_Creatable = False
  178. Attribute VB_PredeclaredId = True
  179. Attribute VB_Exposed = False
  180. Sub CommandButton1_Click()
  181. Tag = "АГА"
  182. Hide
  183. End Sub
  184.  
  185. Sub CommandButton2_Click()
  186. Tag = ""
  187. Hide
  188. End Sub

Paste Details

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.