tekst naar excel ,pdf,versturen

Status
Niet open voor verdere reacties.

jordyvk

Gebruiker
Lid geworden
9 sep 2009
Berichten
56
hallo,

ik ben druk bezig dus dan heb je vaak nog heel wat vragen.

1. ik zou graag een factuur willen maken in excel of iets anders.
2. deze dan opslaan als pdf
3. verzenden via e-mail naar klant

ik heb het via csv gedaan maar dan kan je geen lay-out en zo. (een factuur moet er toch een beetje uitzien.

hier een voorbeeld van factuur

image008.jpg


ik hoop dat iemand mij kan helpen want ik ben pas begonnen met vb.

groeten jordy
 
Ik raad je aan dit in word te maken.
de procedure is niet gemakkelijk en je hebt er office 2007 nodig

gebruik
Imports Microsoft.Office.Interop
 
oke bedankt.

heb je misschien ergens een voorbeeld van zoiets?
ik ben hier namelijk niet zo goed in

office 2007 heb ik.(full)
 
Ik heb geen voorbeeld maar zal wat in elkaar zetten.
zo dat je wat verder kan.
 
Ok Maak als proef voor je zelf een form
met drie textboxen en een button.
en plaats deze code
Dan kan je hier mee Experimenteren om te zien wat er gebeurd

In word maak je een document met drie invoer velden. en noem dit Invuldocument
vul je textboxen met je gegevens
klik op de button en je document word ingevuld

Code:
Imports Microsoft.Office.Interop
Public Class Form1
#Region "Factuur1 Afdrukken "


    ' Open and close word application
    Private Shared wordApp As Microsoft.Office.Interop.Word.Application
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        openWordApp()
        updateWordDocument("C:\Test\Invuldocument.doc") 'gebruikt factuur 
    End Sub
   

    Private Sub updateWordDocument(ByVal documentFileName As String)
        'Word documen invullen
        Dim templateWord As Microsoft.Office.Interop.Word.Document = Nothing
        Try
            openWordApp()
            templateWord = wordApp.Documents.Open(CType(documentFileName, Object))
            templateWord.Bookmarks("Text1").Range.InsertAfter(TextBox1.Text)
            templateWord.Bookmarks("Text2").Range.InsertAfter(TextBox2.Text)
            templateWord.Bookmarks("Text3").Range.InsertAfter(TextBox3.Text)

        Finally

            If Not IsNothing(templateWord) Then

                templateWord.SaveAs("C:\Test\InvulTest.doc")
                templateWord.PrintOut(Copies:=2)
                templateWord.Close()
            End If
            closeWordApp()
        End Try


    End Sub

    Private Shared Sub openWordApp()
        If IsNothing(wordApp) Then
            wordApp = New Microsoft.Office.Interop.Word.Application
            wordApp.Visible = False

        End If

    End Sub
    Private Shared Sub closeWordApp()
        If Not IsNothing(wordApp) Then
            wordApp.Quit()
            wordApp = Nothing
        End If
    End Sub


#End Region

  
End Class

In word maak je een document met drie invoer velden. en noem dit Invuldocument
vul je textboxen met je gegevens
klik op de button en je document word ingevuld

Als je dit werkende hebt begrijp je het Principe en kan je de code aanpassen naar jou behoefde.
als je meer wild weten help ik je wel verder.
 
bij word moet je een veld invoeren maar welke veldnaam moet het hebben?
invoer veld staat er niet bij...

[smallimg]http://img27.imageshack.us/img27/5438/wordveld.jpg[/smallimg]
(Klikbaar)
of doe ik het fout
 
Laatst bewerkt door een moderator:
Open je tabblad ontwikelaars in word te vinden onder opties
zie bijlage
 

Bijlagen

  • open1.jpg
    open1.jpg
    96,9 KB · Weergaven: 82
ik heb een paar fout meldingen

Warning 1 Namespace or type specified in the Imports 'Microsoft.Office.Interop' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
Error 2 Type 'Microsoft.Office.Interop.Word.Application' is not defined.
Error 3 Type 'Microsoft.Office.Interop.Word.Document' is not defined.
Error 4 Type 'Microsoft.Office.Interop.Word.Application' is not defined.
alvast bedankt
 
Je moet wel een Reverense importeren

in VB onder Project Add reverense
onder ned vind je Microsoft.Office.Interop.Word

zonder je reverense werkt het niet
 
oke

alles lukt maar als ik op de knop klik dan slaat hij het op (zoals het hoort)

maar hij opent ook nog een ander venster wat niet moet.

[smallimg]http://img11.imageshack.us/img11/9117/probleemword.jpg[/smallimg]

weet jij misschien hoe je dit weg doet

alvast erg bedankt
 
Laatst bewerkt door een moderator:
Geen Idee
je hebt de code gelaten zo als ik je hem heb gegeven?

onder de button1
Invuldocument.doc dit moet je zien als een sjabloon van je factuur

En
Code:
templateWord.SaveAs("C:\Test\InvulTest.Doc")
let op dat de SaveAS een anderen naam heeft als je invoer document

als je het niet wild printen kan je hier ook naar je mail opdracht verwijzen.

ik zie dat je geen path op geeft bij saveAs
Hopelijk werk het dan voor je
 
Laatst bewerkt:
hallo iedereen

hier ben ik weer.

ik heb een beetje zitten prutsen en dit is er uit gekomen.

Code:
Dim excel_app As Excel.Application
            Dim row As Integer

            ' Create the Excel application.
            excel_app = CreateObject("Excel.Application")

            ' Uncomment this line to make Excel visible.
            excel_app.Visible = False
            ' Create a new spreadsheet.
            excel_app.Workbooks.Add()

            ' Insert data into Excel.
            With excel_app
                .Range("A1:H1").Merge()
                .Range("A1").Select()
                .ActiveCell.FormulaR1C1 = "BorduurCompany"
                .ActiveCell.HorizontalAlignment = Constants.xlCenter
                .Columns("A:A").ColumnWidth = 2
                .Columns("B:B").ColumnWidth = 12
                .Columns("C:C").ColumnWidth = 27
                .Columns("D:D").ColumnWidth = 12
                .Columns("E:E").ColumnWidth = 12
                .Columns("F:F").ColumnWidth = 12
                .Columns("G:G").columnwidth = 2
                .Columns("H:H").columnwidth = 2
                With .Selection.Font
                    .Name = "Century Gothic"
                    .Size = 40
                    .Color = RGB(238, 128, 28)
                End With

                .Range("A2:H2").Merge()
                .Range("A2").Select()
                .ActiveCell.FormulaR1C1 = "It's Me"
                .ActiveCell.RowHeight = 90
                .ActiveCell.VerticalAlignment = Constants.xlCenter
                .ActiveCell.HorizontalAlignment = Constants.xlCenter
                With .Selection.Font
                    .Name = "Another"
                    .Size = 100
                    .Color = RGB(238, 128, 28)
                End With

                .Range("A3:H3").Merge()
                .Range("A3").Select()
                .ActiveCell.FormulaR1C1 = "Merknaam van De Romerij BVBA"
                .ActiveCell.HorizontalAlignment = Constants.xlRight
                With .Selection.Font
                    .Name = "Century Gothic"
                    .Size = 10
                    .Color = RGB(238, 128, 28)
                End With

                .Range("A4:H4").Merge()
                .Range("A4").Select()
                .ActiveCell.RowHeight = 30
                With .Selection.Borders(XlBordersIndex.xlEdgeBottom)
                    .LineStyle = XlLineStyle.xlContinuous
                    .Weight = XlBorderWeight.xlThick
                    .ColorIndex = 0
                End With

                .Range("B5").Select()
                .ActiveCell.FormulaR1C1 = "Factuur"
                .ActiveCell.HorizontalAlignment = Constants.xlLeft
                With .Selection.Font
                    .Name = "Century Schoolbook"
                    .Size = 24
                    .Colorindex = 0
                End With

                .Range("B7").Select()
                .ActiveCell.FormulaR1C1 = "Datum"
                .ActiveCell.HorizontalAlignment = Constants.xlLeft
                With .Selection.Font
                    .Name = "Century Schoolbook"
                    .Size = 11
                    .bold = True
                    .Colorindex = 0
                End With
                .Range("c7").Select()
                .ActiveCell.FormulaR1C1 = "=vandaag()"
                .ActiveCell.HorizontalAlignment = Constants.xlLeft
                With .Selection.Font
                    .Name = "Century Schoolbook"
                    .Size = 11
                    .bold = False
                    .Colorindex = 0
                End With

                .Range("B8").Select()
                .ActiveCell.FormulaR1C1 = "Factuurnr"
                .ActiveCell.HorizontalAlignment = Constants.xlLeft
                With .Selection.Font
                    .Name = "Century Schoolbook"
                    .Size = 11
                    .bold = True
                    .Colorindex = 0
                End With
                .Range("c8").Select()
                .ActiveCell.FormulaR1C1 = DateAndTime.Today.Year() & DateAndTime.Today.Month()
                .ActiveCell.HorizontalAlignment = Constants.xlLeft
                With .Selection.Font
                    .Name = "Century Schoolbook"
                    .Size = 11
                    .bold = False
                    .Colorindex = 0
                End With

                .Range("B10").Select()
                .ActiveCell.FormulaR1C1 = "BTWnr"
                .ActiveCell.HorizontalAlignment = Constants.xlLeft
                With .Selection.Font
                    .Name = "Century Schoolbook"
                    .Size = 11
                    .bold = True
                    .Colorindex = 0
                End With
                .Range("c10").Select()
                .ActiveCell.FormulaR1C1 = btnBTWnummer.Text
                .ActiveCell.HorizontalAlignment = Constants.xlLeft
                With .Selection.Font
                    .Name = "Century Schoolbook"
                    .Size = 11
                    .bold = False
                    .Colorindex = 0
                End With

                .Range("A10:H10").Select()
                With .Selection.Borders(XlBordersIndex.xlEdgeBottom)
                    .LineStyle = XlLineStyle.xlContinuous
                    .Weight = XlBorderWeight.xlThick
                    .ColorIndex = 0
                End With

                .Range("E6:F6").Merge()
                .Range("E6").Select()
                .ActiveCell.FormulaR1C1 = btnnaam.Text
                .ActiveCell.HorizontalAlignment = Constants.xlLeft
                With .Selection.Font
                    .Name = "Century Schoolbook"
                    .Size = 11
                    .bold = True
                    .Colorindex = 0
                End With

                .Range("E7:F7").Merge()
                .Range("E7").Select()
                .ActiveCell.FormulaR1C1 = btnadres.Text & " "

                .ActiveCell.HorizontalAlignment = Constants.xlLeft
                With .Selection.Font
                    .Name = "Century Schoolbook"
                    .Size = 11
                    .bold = True
                    .Colorindex = 0
                End With

                .Range("E8:F8").Merge()
                .Range("E8").Select()
                .ActiveCell.FormulaR1C1 = btnpostcode.Text & " " & btnplaats.Text
                .ActiveCell.HorizontalAlignment = Constants.xlLeft
                With .Selection.Font
                    .Name = "Century Schoolbook"
                    .Size = 11
                    .bold = True
                    .Colorindex = 0
                End With

                row = 4

                .Range("A" & Format$(row)).Select()
                .ActiveCell.Font.Color = RGB(238, 128, 28)
                .ActiveCell.FormulaR1C1 = ""


                ' Save the results.
                .ActiveWorkbook.SaveAs("testzoveel.xlsx")
            End With

            ' Comment the rest of the lines to keep
            ' Excel running so you can see it.

            ' Close the workbook without saving.
            excel_app.ActiveWorkbook.Close(False)

            ' Close Excel.
            excel_app.Quit()
            excel_app = Nothing

            MsgBox("Ok")

ik wil iedereen bedanken voor het helpen.

alleen nog 1 vraagje hoe zet je zo'n bestand om naar pdf?

alvast bedankt

groeten jordy
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan