vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Mails senden, abrufen und decodieren - ganz easy ;-)  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Fortgeschrittene Programmierung
Re: Word Tabelle füllen 
Autor: Stevie B.
Datum: 28.11.07 22:45

Hallo Alosch,

erstmal vielen Dank für Deine Hilfe. Ich poste hier mal die ganze Sub. Vor der Tabelle steht normaler Rechnungstext mit verschiedenen Textmarken.
    Dim n As Long
    Dim WordAppl As Word.Application
    Dim oRange As Word.Range
    Dim WdDoc As Word.Document
    Dim WordApplLiefNicht As Boolean
 
    On Error Resume Next
    Set WordAppl = GetObject(, "Word.Application")
 
    ' Wenn Word nicht ausgeführt wird, Word starten:
    On Error GoTo errorMsgWord
    If WordAppl Is Nothing Then
        WordApplLiefNicht = True
        Set WordAppl = CreateObject("Word.Application")
    End If
 
    ' Dokument öffnen
    On Error GoTo errorMsgVorlage
    WordAppl.Documents.Add _
                    Template:=App.Path & "\" & WordDocVorlage, _
                    NewTemplate:=False
    On Error GoTo 0
 
    Set oRange = WordAppl.ActiveDocument.Sections(1).Range
 
    WordAppl.Selection.MoveRight unit:=wdCell
    WordAppl.Selection.MoveRight unit:=wdCell
    WordAppl.Selection.MoveRight unit:=wdCell
    WordAppl.Selection.MoveRight unit:=wdCell
    WordAppl.Selection.MoveRight unit:=wdCell
    WordAppl.Selection.MoveRight unit:=wdCell
    WordAppl.Selection.MoveRight unit:=wdCell
 
    sSql = "SELECT * FROM tblPositionen WHERE rid=" & rId
    If dbQuery = "ok" Then
        With oRs
            If .RecordCount > 0 Then
                'WordAppl.ActiveDocument.Tables.Add Range:=oRange, 
                ' NumRows:=.RecordCount, NumColumns:=7, _
                'DefaultTableBehavior:=wdWord9TableBehavior, 
                ' AutoFitBehavior:=wdAutoFitFixed
 
                With WordAppl.Selection.Tables(1)
                    .ApplyStyleHeadingRows = True
                    .ApplyStyleLastRow = True
                    .ApplyStyleFirstColumn = True
                    .ApplyStyleLastColumn = True
                End With
 
                n = 1
                Do While Not .EOF
                    'LFD
                    WordAppl.Selection.TypeText n & "."
                    WordAppl.Selection.MoveRight unit:=wdCell
                    'Datum
                    WordAppl.Selection.TypeText .Fields("datum").Value
                    WordAppl.Selection.MoveRight unit:=wdCell
                    'Leistung
                    WordAppl.Selection.TypeText Replace(.Fields( _
                      "leistung").Value, "'", "'")
                    WordAppl.Selection.MoveRight unit:=wdCell
                    'Stundensatz
                    WordAppl.Selection.TypeText cfgPreis(CLng(.Fields( _
                      "satz").Value))
                    WordAppl.Selection.MoveRight unit:=wdCell
                    'Stunden
                    WordAppl.Selection.TypeText CDbl(CLng(.Fields( _
                      "stunden").Value) / 100)
                    WordAppl.Selection.MoveRight unit:=wdCell
                    'MwSt
                    WordAppl.Selection.TypeText CDbl(CLng(.Fields( _
                      "mwst").Value) / 100)
                    WordAppl.Selection.MoveRight unit:=wdCell
                    'Betrag
                    WordAppl.Selection.TypeText cfgPreis(CLng(.Fields( _
                      "betrag").Value))
                    If n < .RecordCount Then WordAppl.Selection.MoveRight _
                    unit:=wdCell
                    n = n + 1
                    .MoveNext
                Loop
 
                WordAppl.Visible = True
                Set WordAppl = Nothing
                Set oRange = Nothing
            End If
            .Close
        End With
        Set oRs = Nothing
    Else
        MsgBox dbQuery, vbCritical, App.Title
    End If
    Call CloseConn
 
    Screen.MousePointer = 0
Das Füllen der Textmarken habe ich mal raus gelassen, da der Text sonst zu lang ist.

Gruß,
Stevie b.
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Word Tabelle füllen2.706Stevie B.27.11.07 12:10
Re: Word Tabelle füllen1.621alosch28.11.07 04:39
Re: Word Tabelle füllen1.626Stevie B.28.11.07 08:58
Re: Word Tabelle füllen1.908alosch28.11.07 22:31
Re: Word Tabelle füllen2.056Stevie B.28.11.07 22:45
Re: Word Tabelle füllen1.580Stevie B.28.11.07 23:16
Re: Word Tabelle füllen1.595alosch28.11.07 23:43
Re: Word Tabelle füllen1.625alosch28.11.07 23:33
Re: Word Tabelle füllen1.576Stevie B.28.11.07 23:40
Re: Word Tabelle füllen1.568alosch28.11.07 23:47
Re: Word Tabelle füllen1.548Stevie B.28.11.07 23:53

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel