Read a Microsoft Word Document into Scintilla

Share your advanced PureBasic knowledge/code with the community.
michaeled314
Enthusiast
Enthusiast
Posts: 340
Joined: Tue Apr 24, 2007 11:14 pm

Read a Microsoft Word Document into Scintilla

Post by michaeled314 »

Quick + Simple with DispHelper Library

4.10 Beta 4

Code: Select all

Procedure Scintilla(EditorGadget.l,*scinotify.SCNotification)
EndProcedure

If OpenWindow(0,0,0,500,500,"Test",#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
 
 If InitScintilla("scintilla.dll") = #False
  End
 EndIf
 
 If CreateGadgetList(WindowID(0))
  ScintillaGadget(0,20,20,460,460,@Scintilla())
 EndIf
 
 If CreateMenu(0,WindowID(0))
  MenuTitle("File")
   MenuItem(0,"New [Ctrl+N]")
   MenuItem(1,"Open [Ctrl+O]")
   MenuItem(2,"Save [Ctrl+S]")
   MenuItem(3,"Save As")
   MenuItem(4,"Save As Web Page")
   MenuItem(5,"Exit [Esc]")
 EndIf
 
 Repeat
  Event = WindowEvent()
  Select Event
   Case #PB_Event_Menu
    Select EventMenu()
     Case 1
      path$ = ""
      SHGetSpecialFolderLocation_(WindowID(0),#CSIDL_PERSONAL,@path$)
      file$ = OpenFileRequester("Please choose file to load",path$,"Word Document (*.doc)|*.doc",0)
      dhToggleExceptions(#True)
      oWord = dhCreateObject("Word.Application")
      If oWord
       dhCallMethod(oWord,"Documents.Open(%s)",@file$)
       dhCallMethod(oWord,"Selection.WholeStory()")
       dhCallMethod(oWord,"Selection.Copy()")
       ScintillaSendMessage(0,#SCI_CLEARALL)
       ScintillaSendMessage(0,#SCI_PASTE)
      EndIf
    EndSelect
  EndSelect
 Until Event = #PB_Event_CloseWindow 
EndIf