Private I as integerPrivate macroname as stringprivate word on words word.documentprivate se1 as word.selectionprivate db as dataprivate rs as recordset
Private Sub Cmdadd_Click () DIM stmp as string stmp = inputbox ("Enter the new item you want to add:") if len (stmp) = 0 Then Exit Sub Lstitems.AddItem Stmpend Sub
Private Sub cmdDelete_Click () If lstItems.ListIndex> -1 Then If MsgBox ( "Delete '" & lstItems.Text & "'?", VbQuestion vbYesNo) = vbYes Then lstItems.RemoveItem lstItems.ListIndex End If End IfEnd Sub
Private Sub Cmdup_Click () ON Error Resume Next Dim NITEM AS INTEGER with LSTITEMS IF .LISTINDEX <0 THEN EXIT SUB NISTINDEX Private Sub Cmddown_Click () ON Error Resume Next Dim Nitem AS Integer with Lstitems if .listIndex <0 Then EXIT SUB NIT SUB NITEM = .ListIndex if NITEM = .ListCount - 1 THEN EXIT SUB 'Can't move the last item down to move down Item .additem .Text, Nitem 2 'Delete old items. RemoveItem NItem' Select the project just moved. Sselected (NItem 1) = true end wirth Private Sub lstItems_DragDrop (Source As Control, X As Single, Y As Single) Dim i As Integer Dim nID As Integer Dim sTmp As String If Source.Name <> "lstItems" Then Exit Sub If lstItems.ListCount = 0 Then Exit Sub With LSTITEMS I = (Y / textHeight ("a")) .topIndex if i = .listindex the 'put it in its own EXIT SUB END IF I> .listcount - 1 Then i = .listcount - 1 NID = .ListIndex sTmp = .Text If (nID> -1) Then sTmp = .Text .RemoveItem nID .AddItem sTmp, i .ListIndex = .NewIndex End If End With SetListButtonsEnd SubSub lstItems_MouseMove (Button As Integer, Shift As Integer, X As SINGLE, Y askLE) ifeton = vbleftbutton dam = vbleftbutton Private sub lstitems_click () setListButtonsend Sub Sub setListButtons () DIM I as integer i = lstractitems.listIndex 'Set status cmdup.enabled = (i> 0) cmddown.enabled = ((i> -1) and (i <(i> -1) and (i <(lstractitems.listcount - 1) )) Cmddelete.enabled = (i> -1) End Sub Private submmand1_click () With dlgcommondialog label4.caption = .initdir .dialogtitle = "Open DBF file" .cancelerror = false 'Todo: Sets the flag and properties of the CommON Dialog control. Filter = "All DBF files (* .dbf) | * .dbf" .showopen If Len (.filename) = 0 THEN EXIT SUB End if sfile = .filename label1.caption = sfile label2.caption = .fileTitle Label3.caption = Left (sfile, len (sfile) - LEN (.fileTitle) - 1) DATA1 .Caption = .FileTitle End With 'Data1.Database = Label3.Caption Data1.DatabaseName = Label3.Caption Data1.RecordSource = Label2.Caption' On Error Resume Next Data1.Refresh 'Form1.MSFlexGrid1.Refresh Form1.DBGrid1.Refresh Form1. Refreshend Subprivate Sub Command2_Click () Endend Sub Private submmand3_click () if label2.caption = "dbffile:" THEN CALL Command1_click end ifset db = data1.databaseset = data1.recordsetdata1.refresh SET WORDAPP = New Word.ApplicationWordApp.documents.addset Doc = Wordapp.ActiveDocumentSet Se1 = Wordapp.Serection With doc.PageSetup .LineNumbering.Active = False .Orientation = wdOrientLandscape .TopMargin = CentimetersToPoints (2) .BottomMargin = CentimetersToPoints (2) .LeftMargin = CentimetersToPoints (2) .RightMargin = CentimetersToPoints (2) .Gutter = CentimetersToPoints (0). HeaderDistance = CentimetersToPoints (1.5) .FooterDistance = CentimetersToPoints (1.75) .PageWidth = CentimetersToPoints (29.7) .PageHeight = CentimetersToPoints (21) .FirstPageTray = wdPrinterDefaultBin .OtherPagesTray = wdPrinterDefaultBin .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = WDALIGNVERTICALTOP .SUPPRESSENDNOTES = false .mirrorMargins = false .twopagesonone = false .gutterpos = wdgutterposleft .la Youtmode = WDLAYOUTMODELINEGRID End with se1.typetext text: = "20" & cstr (date) & "& cstr (time ()) 'doc.tables.add range: = se1.range, nuMrows: = 1, NumColumns: = List2.listcount doc.tables.add range: = se1.range, nuMrows: = 1, numcolumns: = rs.fields.count for i = 0 to rs.fields.count - 1Screen.Mousepointer = 11'se1.typetext text: = rs.fields (i) .namese1.typetext text: = rs.fields (i) .namese1.moveright unit: = 12Next 'se1.typetext text: = "Product Name"' Se1.Moveright Unit: = 12 Do Until Rs.eof for i = 0 to rs.fields.count - 1 on Error Resume Next Se1.Typetext text: = rs.fields (i) .Value 'se1.typetext text: = rs.fields (rs.fields i)))). Value se1.moveright unit: = 12 next'se1.typetext text: = rs! Product Name 'se1.moveright unit: = 12'se1.typetext text: = rs! Medicinal' se1.moveright unit: = 12 rs.MoveNext LoopWordApp.Run MacroName: = "AutoFitContent" se1.InsertBreak se1.Delete Count: = rs.Fields.Count se1.Sections (1) .Footers (1) .PageNumbers.Add PageNumberAlignment: = _ wdAlignPageNumberRight, FirstPage: = True Wordapp.visible = true 'WordApp.run macroname: = "InsertDatetime" set wordapp = NothingScreen.MousePointer = 1'Data1.Recordset.fields () end SUB Private sub exit_click () Close Endend Sub Private sub open_click () call command1_clickend sub