23. januar 2002 - 13:17Der er
3 kommentarer og 2 løsninger
Flytte dokumentindhold til tekstbehandlingsprogram
Hvordan gør man hvis man skal lave en funktion, der flytter/kopiere indholdet af et dokument over i feks. Word Pro. Funktionen skal være så nem at anvende, at selv min afdøde tipoldefar kan bruge den. Forslag modtages med glæde..
I dette særtema om aspekter af AI ser vi på skiftet fra sprogmodeller til AI-agenter, og hvordan virksomheder kan navigere i spændet mellem teknologisk hastighed og behovet for menneskelig kontrol.
Hep, ja det kunne jeg også godt tænke mig at vide :-) Jeg nået frem til et par løsninger
1) Den klassiske objektmetode. Man kan lægge et wordobjekt ind i et notes dokument og lave field exchange mellem de 2. Dermed bliver de generede dokument også gemt i notes, hvilket kan være en fordel. Ulempe: Kanon ustabilt at arbejde med objekter.
2) OLE-VBA Jeg har et script, som via OLE oprettet et excelark, og lægger alle data fra et view over i den. Den burde kunne rettes til at lave et worddokument i stedet...
Her er scriptet, det kopieres blot ind i en agent der benytter lotus script Sub Initialize 'Create an Excel Spreadsheet from any view '11/3/2000 Art Yates Dim Session As New NotesSession ,db As NotesDatabase Dim sourceview As NotesView,sourcedoc As NotesDocument Dim dataview As NotesView, dc As NotesDocumentCollection Dim datadoc As NotesDocument, maxcols As Integer Dim WS As New Notesuiworkspace Dim ViewString As String, Scope As String, GetField As Variant Dim C As NotesViewColumn, FieldName As String, K As Integer,N As Integer Dim xlApp As Variant, xlsheet As Variant, rows As Integer, cols As Integer Dim nitem As NotesItem , entry As NotesViewEntry, vwNav As NotesViewNavigator Dim ShowView() As Variant, i As Integer, VList As Variant, ColVals As Variant
Set db = session.CurrentDatabase 'link to current database
'fetch then display a list of views in the database Vlist= db.views K=Ubound(Vlist) 'get size of list Redim Preserve ShowView(K) N=-1 For i = 0 To K If Len(Vlist(i).Name) >0 Then FieldName=Trim(Vlist(i).Name) If Mid(Fieldname,1,1) <>"(" Then 'do not show hidden views N=N+1 ShowView(N) = FieldName End If End If Next i Redim Preserve ShowView(N) 'now sort the list - by default views are listing in the order that they were created For i=0 To N For K=i To N If ShowView(i) > ShowView(k) Then FieldName=ShowView(i) ShowView(i) = ShowView(k) ShowView(k)=FieldName End If Next k Next i
viewstring= ws.Prompt(PROMPT_OKCANCELLIST,"List of Views","Choose a View","",ShowView ) If Len(viewstring)=0 Then Exit Sub 'ViewString ="Dan's View"
Set dataview = db.getview(ViewString) 'get selected view
Set vwnav= dataview.createViewnav()
rows = 1 cols = 1 maxcols=dataview.ColumnCount 'how many columns?
Set xlApp = CreateObject("Excel.Application") 'start Excel with OLE Automation xlApp.StatusBar = "Creating WorkSheet. Please be patient..." xlApp.Visible = True xlApp.Workbooks.Add xlApp.ReferenceStyle = 2 Set xlsheet = xlApp.Workbooks(1).Worksheets(1) 'select first worksheet
'worksheet title xlsheet.Cells(rows,cols).Value ="View: " + ViewString + ", from Database: " + db.title +", Extract created on: " + Format(Now,"mm/dd/yyyy HH:MM")
xlApp.StatusBar = "Creating Column Heading. Please be patient..."
rows=2 'column headings starts in row 2 For K=1 To maxcols Set c=dataview.columns(K-1) xlsheet.Cells(rows,cols).Value = c.title cols = cols + 1 Next K
Set entry=vwnav.GetFirstDocument rows=3 'data starts in third row Do While Not (entry Is Nothing)
For cols=1 To maxcols colvals=entry.ColumnValues(cols-1) 'subscript =0 scope=Typename(colvals) Select Case scope Case "STRING" xlsheet.Cells(rows,cols).Value ="'" + colvals Case Else xlsheet.Cells(rows,cols).Value = colvals End Select Next cols xlApp.StatusBar = "Importing Notes Data - Document " & rows-1 '& " of " & dc.count & "." rows=rows+1 Set entry = vwnav.getnextdocument(entry) Loop
xlApp.Rows("1:1").Select xlApp.Selection.Font.Bold = True xlApp.Selection.Font.Underline = True xlApp.Range(xlsheet.Cells(2,1), xlsheet.Cells(rows,maxcols)).Select xlApp.Selection.Font.Name = "Arial" xlApp.Selection.Font.Size = 9 xlApp.Selection.Columns.AutoFit With xlApp.Worksheets(1) .PageSetup.Orientation = 2 .PageSetup.centerheader = "Report - Confidential" .Pagesetup.RightFooter = "Page &P" & Chr$(13) & "Date: &D" .Pagesetup.CenterFooter = "" End With xlApp.ReferenceStyle = 1 xlApp.Range("A1").Select xlApp.StatusBar = "Importing Data from Lotus Notes Application was Completed." 'xlapp.ActiveWorkbook.saveas "c:VX" + Trim(Format(Now,"yyy")) 'save with generated name dataview.clear
Set xlapp=Nothing 'stop OLE Set db=Nothing End Sub
Lav en action button med et script i stil med nedenstående. Den prompter for et filnavn go exporterer enkelte felter til en textfil, som launches i WordPro
Sub Initialize Dim Session As NotesSession Dim Db As NotesDatabase Dim Col As NotesDocumentCollection Dim Doc As NotesDocument Dim FF As Integer Dim FilePath As String Dim FullDesc As String Dim RTFFElt As NotesRichTextitem
FF = Freefile
FF = Freefile FilePath=Inputbox("File Path") If FilePath <> "" Then Open FilePath For Output As #FF Set Session = New NotesSession Set Db = Session.CurrentDatabase Set Col = Db.UnprocessedDocuments Set Doc = Col.GetFirstDocument Write #FF,"Header 1" ,"Header 2" ,"Header-n" Do While Not Doc Is Nothing With Doc Set RTFFelt=.GetFirstItem( "FullRequestDescription" ) FullDesc= RTFFelt.GetFormattedText( True, 0) Write #FF,Felt1, Felt2, FullDesc, Felt-n End With Set Doc = Col.GetNextDocument(Doc) Loop Close #FF End If Shell ( "Drive:\path\wordpro.exe FilePath" ) End Sub
Tak for hjælpen. Resultatet er nogenlunde hvad jeg har brug for, dog ved WordPro stadig ikke at det er .lwp format, og spørger om man vil fortsætte ved valg af 'Gem Som' (Vælges JA, gemmes som text, vælges NEJ gemmes som .lwp) Men det er langt bedre end tidligere versioner.
Sådan skal det gøres, med smartmaster med koden i: Sub Documentopened(Source As Wpapplication, Docname As String) .paste End Sub
Og følgende knapkode i lotus dokument: Sub Click(Source As Button) Dim workspace As New NotesUIWorkspace Dim uidoc As NotesUIDocument Set uidoc = workspace.CurrentDocument Dim svar As Integer
If uidoc.EditMode Then uidoc.editmode = 0 Msgbox "Dokumentet var i redigeringstilstand. For at fortsætte skal du trykke på 'GørDetLet' igen", 0 + 63, "Hjælp til kopiering" Exit Sub Else Call uidoc.ExpandAllSections End If
'Nu markeres og kopieres uidoc.editmode = 0 Call uidoc.SelectAll Call uidoc.Copy
'Noget kode til at åbne WordPro, eller oprette WordPro, eller åbne en vedhæftet smartmaster i WordPro. Dim taskID As Integer Dim smaster As Variant Dim navn As String Dim filcheck As String
navn = uidoc.fieldgettext("UNID") '"WP123456789" filcheck$ = Dir$("C:\"+ navn+".lwp",0) If filcheck= "" Then Set smaster = CreateObject("WordPro.Application") smaster.Application.NewDocument navn+".lwp","C:\" ,"" ,"C:\lotus\smasters\wordpro\VPSmartmaster.mwp","","" smaster.Application.Save smaster.Application.Quit End If navn = "c:\"+navn+".lwp" taskID% = Shell("cmd.exe /c START " + navn)
End Sub
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.