home *** CD-ROM | disk | FTP | other *** search
/ In'side Shareware 1995 April / ish0495.iso / win95 / zipserv / wordcode.tx_ / wordcode.tx
Text File  |  1995-01-24  |  3KB  |  78 lines

  1. 'This code is applicable for MsWord V.6.0
  2.  
  3. 'Place the following code in a WordBasic Macro 
  4. 'called Backup. Consult with Word's Help for how to create and run
  5. 'a Macro.
  6.  
  7. Dim Shared Channel, SourceApp$, SourceForm$, SourceControl$
  8. Sub MAIN
  9.     On Error Resume Next
  10.     If AppIsRunning("Hidden DDE Server") = 0 Then  
  11.        'Note: "Hidden DDE Server" is the Caption value of ZipForm
  12.        Shell "C:\ZIPSERV\ZIPSERV.EXE -1"
  13.     End If
  14.     SourceApp$ = "ZIPSERV"
  15.     SourceForm$ = "ZipForm"
  16.     SourceControl$ = "DDELabel"
  17.     Counter = 0
  18.     While AppIsRunning("Hidden DDE Server") = 0
  19.           Counter = Counter + 1
  20.           If Counter = 100 Then Goto AfterWend
  21.     Wend
  22. AfterWend:
  23.     If Not AppIsRunning("Hidden DDE Server") = 0 Then  
  24.        Channel = DDEInitiate(SourceApp$, SourceForm$)
  25.     Else
  26.        MsgBox "Execution failed. Please repeat Backup"
  27.     EndIf
  28.     If Channel <> 0 Then
  29.        'application running
  30.        'in the example we are sending a message to zip all .DOC files
  31.        'into an WORDDOC.ZIP file in the same directory
  32.        'we are using as directory C:\MSOFFICE\WINWORD
  33.        WordDir$ = "C:\MSOFFICE\WINWORD\"
  34.        ZipFile$ = WordDir$ + "WORDDOC.ZIP"
  35.        FilesToZip$ = WordDir$ + "*.DOC"
  36.        KeepDate$ = "0" 'Change to "1" when updating and keep date  
  37.            StorePath$ = "0" 'Change to "1" when Yes
  38.            Recursive$ = "0" 'Change to "1" when Yes
  39.        Comment$ = ""    'No comment
  40.        Password$  = ""  'No password
  41.        Task$ = "0"      'Zipping, change it to "1" for unzipping
  42.        s$ = ""   
  43.        s$ = s$ + Left$(ZipFile$ + String$(100, " "), 100)
  44.        s$ = s$ + Task$
  45.        If Task$ = "0" Then
  46.           s$ = s$ + Left$(FilesToZip$ + String$(100, " "), 100)
  47.       s$ = s$ + KeepDate$
  48.           s$ = s$ + StorePath$
  49.           s$ = s$ + Recursive$
  50.        Else
  51.           s$ = s$ + Left$(Destination$ + String$(100, " "), 100)
  52.           s$ = s$ + Overwrite$      ' "0" - No  ,  "1" - Yes
  53.           s$ = s$ + RestorePath$    ' "0" - No  ,  "1" - Yes 
  54.        EndIf
  55.        s$ = s$ + Left$(Comment$ + String$(50, " "), 50)
  56.        s$ = s$ + Left$(Password$ + String$(10, " "), 10)
  57.        SendDDE s$
  58.        SendDDE ""  'Unloads Zip Server
  59.     EndIf
  60. ExitMain:
  61. End Sub
  62.  
  63. Sub SendDDE(DDEInstruction$)
  64.     'Send and receive DDE commands/results to/from the
  65.     'hidden Zip server, using the local DDELabel control
  66.     DDEPoke Channel, SourceControl$, DDEInstruction$
  67.     If UCase$(DDEInstruction$) <> "" Then
  68.        Response$ = DDERequest$(Channel, SourceControl$)
  69.        While Response$ = DDEInstruction$    'wait for execution
  70.           Response$ = DDERequest$(Channel, SourceControl$)
  71.        Wend
  72.        'MsgBox "Zip Server's Response: " + Response$
  73.        'you do not need this MsgBox, but might want to use 
  74.        'Response$ value
  75.        'in the application. Note that it returns "-1" if the execution                  'was successfull
  76.     EndIf
  77. End Sub
  78.