Solved

Creating a PDF File

Posted on 2013-12-03
5
330 Views
Last Modified: 2013-12-05
We are writing a program for ach transactions in our erp software. We have created a word template which will print a summary of the transaction. We also want the word template to be in pdf format. I have a print button with some test code that creates the pdf. The code works to a point but what is happening is that adobe reader will open and stays open in the task bar. It does not close automatically. If someone could help that would be great. Below is my test code:

                The “CreateNoWindow” keeps the Adobe window from showing, but it’s still in the Taksbar tray.


For x = 1 To 1
strVendor = "1070"
Dim arrFile = "C:\Apps\86\PDFs\Remit_1140_66482_12022013_12022013135501_1.pdf"
            Dim startInfo As New ProcessStartInfo
            startInfo.FileName = strFile
            startInfo.CreateNoWindow = True
            startInfo.Verb = "print"
            startInfo.Arguments = ""
            startInfo.UseShellExecute = True

            startInfo.CreateNoWindow = False

            Dim reportPrint As Process = New Process
            reportPrint.StartInfo = startInfo
            reportPrint.Start()
            reportPrint.CloseMainWindow()
            reportPrint.Close()
       Next
0
Comment
Question by:tmaususer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:tmaususer
ID: 39692404
Sorry I should have added. What I am looking for is once the print button in pressed, the pdf prints and adobe closes automatically and not stay open in the task bar
0
 

Author Comment

by:tmaususer
ID: 39694032
I'm going to up the points in the hopes for a response.
0
 
LVL 23

Accepted Solution

by:
Michael74 earned 500 total points
ID: 39694453
Add

reportPrint.Kill();

after

reportPrint.Close()

Michael
0
 

Author Comment

by:tmaususer
ID: 39695282
Michael,

That works but because it is in a loop after the kill process it does not restart (due to the loop) how would I get this to restart? Does that make sense?
0
 
LVL 23

Expert Comment

by:Michael74
ID: 39696926
I am not sure what you are after. The loop only runs once in your code ie

for x = 1 to 1

If you are creating multiple pdf's you should be able to create and dispose of the process object for each run of the code. If you need access to the process outside of the loop declare the reportprint process outside of the loop and then kill it as required.

If I have missed the point please advise

Michael
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create a Dropdown list with sub group 10 43
Convert VB web project to C# 3 66
VB6 calling COM DLL written in Visual Studio 2003 6 57
I need to clear List Box in MVVM panel. 15 27
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question