5 Replies - 538 Views - Last Post: 29 April 2011 - 08:31 PM Rate Topic: -----

#1 Mr Dylan  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 25-March 09

Looking for Printing/Document Exporting Guidence

Posted 29 April 2011 - 06:51 PM

First, let me explain the situation.

I am attempting to create an application that a staff member inputs some data, and it is exported with an option to print.

The problem being I have some strict standards that I need to stick to
One being page layout, certain graphics are required on the page.

A very basic idea of what I am trying to create is a program that looks like this:

Posted Image

Then, when the staff member clicks generate it prints something very similar to:

Posted Image

Really, my question to you is, where do I begin?

Should I look into Vb.Net printing? Should I look into some type of document exporting (IE Export into a word document?)

Or a whole new approach entirely?

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: Looking for Printing/Document Exporting Guidence

#2 _HAWK_  Icon User is online

  • Master(Of Foo)
  • member icon

Reputation: 1065
  • View blog
  • Posts: 4,170
  • Joined: 02-July 08

Re: Looking for Printing/Document Exporting Guidence

Posted 29 April 2011 - 06:58 PM

You could use pure graphics for that with a Printdocument. You could make an image of that screen shot based on the control/form size and import it into word. So it really depends on what you want. The document type will be the selling point for you I think.
Was This Post Helpful? 0
  • +
  • -

#3 Mr Dylan  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 25-March 09

Re: Looking for Printing/Document Exporting Guidence

Posted 29 April 2011 - 07:03 PM

I was thinking that exporting into a document would be the best way to go (.docx specifically)

But I'm not really quite sure where to even begin.
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is online

  • Master(Of Foo)
  • member icon

Reputation: 1065
  • View blog
  • Posts: 4,170
  • Joined: 02-July 08

Re: Looking for Printing/Document Exporting Guidence

Posted 29 April 2011 - 07:12 PM

This is what we call writing to word documents: Word automation.. The method you will looking for is the oDoc.Tables(4).Rows(3).Cells(1).Range.InlineShapes.AddPicture(<path to image>). See what you can come up with for the image capture.
Was This Post Helpful? 0
  • +
  • -

#5 Mr Dylan  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 25-March 09

Re: Looking for Printing/Document Exporting Guidence

Posted 29 April 2011 - 08:08 PM

That link was help towards a great start.


I figured out some basic text insertion, and then google'd my way into Image insertion at first I tried the following code:

objDoc.InlineShapes.AddPicture(FileName:="3", LinkToFile:="C:\Users\Dylan\Pictures\", SaveWithDocument:=True)



Then quickly realized some mistakes and changed it to

objDoc.InlineShapes.AddPicture(FileName:="C:\Users\Dylan\Pictures\3.jpg", LinkToFile:=True, SaveWithDocument:=True)



Therefore making my total compiled code:
Imports Microsoft.Office.Interop.Word
Imports Word = Microsoft.Office.Interop.Word
Public Class Form1
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim objApp As Word.Application
        Dim objDoc As Word.Document

        'Open new instance
        objApp = New Word.Application
        objDoc = New Word.Document

        objDoc = objApp.Documents.Add()
        objDoc.Activate()
        objApp.Selection.TypeText(TextBox1.Text)
        objDoc.InlineShapes.AddPicture(FileName:="C:\Users\Dylan\Pictures\3.jpg", LinkToFile:=True, SaveWithDocument:=True)
        objDoc.SaveAs("C:\Users\Dylan\Desktop\Test.docx")

        'Dispose the Word objects
        objDoc.Close()
        objApp.Quit()
        objDoc = Nothing
        objApp = Nothing
    End Sub
End Class



Thankfully it ran nice.

Now I'm I need to begin figuring out How to add images in specific locations, and add text in specific locations.

How do you recommend this?
Was This Post Helpful? 0
  • +
  • -

#6 _HAWK_  Icon User is online

  • Master(Of Foo)
  • member icon

Reputation: 1065
  • View blog
  • Posts: 4,170
  • Joined: 02-July 08

Re: Looking for Printing/Document Exporting Guidence

Posted 29 April 2011 - 08:31 PM

Something you must know about automation, be it word or excel. You must dispose of it properly. Marshal.FinalReleaseComObject(<com object>) is how to do it with Com objects. Otherwise you will see the process is still hanging most of the time. DrawToBitmap is what I was thinking of.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1