Advertisement
duck__boy1981

Export document (form)

Jan 19th, 2015
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2.  
  3. '**
  4. ' Populate the 'comChooseDocument' combobox every time the 'frmChooseDocument' user form is shown
  5. '*
  6. Private Sub UserForm_Activate()
  7.    
  8.     '** Turn off screen updating so that the user is oblivious *'
  9.    Application.ScreenUpdating = False
  10.    
  11.     '** Remove all items currently in the combobox *'
  12.    Dim i As Integer
  13.     For i = 1 To Me.comChooseDocument.ListCount
  14.         Me.comChooseDocument.RemoveItem 0
  15.     Next i
  16.    
  17.     '** Get all of the 'heading 1' new starter documents titles to add to the combobox (do this every time in case the doucment has changed)*'
  18.    Dim headings() As String
  19.     headings = Functions.GetHeadings
  20.        
  21.     '** Loop through each 'heading' and add it to the combobox *'
  22.    Dim heading As Variant
  23.     For Each heading In headings
  24.         Me.comChooseDocument.AddItem heading
  25.     Next
  26.    
  27.     '** Turn the screen updating back on *'
  28.    Application.ScreenUpdating = True
  29.    
  30.     '** Set the combobox to the first entry, so that there is never a blank selection *'
  31.    If Not Me.comChooseDocument.ListCount = 0 Then
  32.         Me.comChooseDocument.ListIndex = 0
  33.     Else
  34.         Me.Hide
  35.         MsgBox "Sorry, there is no valid 'Heading 1' styled text within your document." & vbCrLf & vbCrLf & "Please ensure that the heading of any new starter document that you wish to export is styled as 'heading 1' and try again.", vbInformation, "No New Starter Documents Found"
  36.     End If
  37.  
  38. End Sub
  39.  
  40. '**
  41. ' Ensure that the 'comChooseDocument' has a value before enabling the 'OK' button
  42. '*
  43. Private Sub comChooseDocument_Change()
  44.    
  45.     '** Check to see if the combobox has s value *'
  46.    If Not comChooseDocument.value = "" Then
  47.         btnOK.Enabled = True
  48.     Else
  49.         btnOK.Enabled = False
  50.     End If
  51.    
  52. End Sub
  53.  
  54. '**
  55. ' Hide the 'frmChooseDocument' user from if the user clicks 'Cancel'
  56. '*
  57. Private Sub btnCancel_Click()
  58.     Me.Hide
  59. End Sub
  60.  
  61. '**
  62. ' Start the document export process when the user clicks 'OK'
  63. '*
  64. Private Sub btnOK_Click()
  65.  
  66.     Me.Hide
  67.    
  68.     '** Attempt to export the document as selected by the user *'
  69.    Dim result As Boolean
  70.     result = Functions.StartExportDocument(comChooseDocument.value)
  71.    
  72.     '** Check to see if the export process was successful *'
  73.    Call Functions.CheckResult(result)
  74.    
  75. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement