Home » MS Office

How to use VB.Net code to close PDF Files being opened in Acrobat ?

By usng some SDK and customized coed, I can open PDF Files in Acrobat using VB.Net. But I can not get them closed. Can anybody help ?


1 Answer Found


Answer 1

Even if the PDF files  have been generated, somehow, by Access, that is more a question about the SDK you use. It probably gives you some object variable which can reach the document, and probably you can "close" it trough one of its method. But again, it is unlikely to have anything to do with Microsoft Access, isn't it?


please i need C# code printing pdf file with acrobat reader 8

How can we open PDF, Word file, Excel file, Jpeg file, Tif files within a VB.Net Application? I tried process.start command unfortunately it opens another Adobe Reader window to open the file.

I want all these files to open within a VB.Net application.

Help appreciated.

I want to create an Windows application in VB.Net which is Read an Acrobat Reader PDF Files. I set the file by Open File dialog box. It's read the PDF file line by line show into multi line Text Box. Please help me. Dot Net framework 2.0

Hi guys;

I want to close form and open another one without terminate the application, when I try open second form and close first one the application terminate.

please advise



I am developing an application which sends multiple AT commands to a modem in VB.Net. After writing an AT command to the modem, I see the dataReceived event is not getting triggered until I close the port & open it again & write the next AT command. This behavior is consistent. As soon as I write the next AT command the response of previous AT command is read. Even adding a delay between the two write operations does not work. I also added a readData between the two writes so that data is read if it exist in buffer or stream but is not triggering datareceived event because bytestoread is non-zero, but that does not hep too. Because of insufficient read operations the data in readbuffer grows(accumulating) & after sometime the modem stops receiving the AT commands. Please suggest a solution

code for data received handler & read data function


While comPort.BytesToRead > 0

    Dim msgCharArray(255) AsChar


    If comPort.BytesToRead >= 256 Then

    comPort.Read(msgCharArray, 0, 256)



   comPort.Read(msgCharArray, 0, comPort.BytesToRead)






I'm using Vb.net 2010 Express, and I need to access the Adobe Acrobat 9 sdk to be able to use the snapshot tool and select the whole page then paste it into a word doc.

I have been able to open and access the pdf and word doc I just can't figure out how to set the Snapshot Tool in Acrobat. Any help would be great.





Dear All,

I need help to read PDF file contents through VFP code or convert PDF file to DOC. My task is -we are receiving some same format PDF file quotations, we want to automate this process, like read PDF file content automatically and feed into our system this will reduce more manual work. So i need your help to read PDF content programmetically through VFP code or convert PDF file to DOC. After that i will use word application object i will read word file.

Kindly help me to convert PDF or READ PDF files.

Thanks and Regards



I am looking for code or a library so that I can open a PDF file, page through it and pass each page to another process.  I want this to be independent of Adobe products.

I have an asp.net application with requirment print pdf from webform with database operation using itext. So i want to handl the pdf print as dynamicaly. So i am decided to  create 4 pdf . one for master Data bind with first pdf. Second for subform data(One Disease form) and 3rd and forth also same as second form for another disease information..    So when the user will choose the disease selection using the checkbox. Based up on that selection i want to print the data how the it comes  to webform same i want to print in pdf when click on the print buttton . So i decided to impliment my logic that is for examble when a user submit the data with master entry field in a panel after that he selected check box with subfrm 2nd and 4 th out 4 check box then panel  with sub form 2nd and 4 th  will be coming there then submit. Then again user go to seach based up on the id  and bring the records from table then disply it on webform. After that user go to click on the print button. I already created 5 seperate pdf file with template (checkbox ,radio button,texbox all those things are in pdf already for each). So firat master pdf for all if there any check box selection came. Then take 2nd pdf and 4th from the directory then bind data. Later on i want to merge it as single one (single pdf). First page will be master data then next page 2nd subform  then 3rd page for 4th subform. after merge this one bring it another directrory(Merged copy with our id as file name stored here then take it for print) and print that .

So i kindly asking my logic is simple or complicated idea. if there any simple this available for dynamic pdf handling. Plz send the detals and url  with souce code.

If possible develop one simple application with same requirment and send it me.

Also i need the code help for it.

I worrying abt it how to handle this one



Hi Dudes,

I need to open a secured Password Protected pdf files problematically in asp.net using c#

I don't want to enter the password manually when its opening time...

but  when its in system it must ask the password to read or print the file

Hope somebody can help me in this


I want to open a .PDF file on button click or hyperlink.

please help me.


i try below code


Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared


'In Class

Dim customerReport As ReportDocument

customerReport = New ReportDocument()

Dim reportPath As String = Application.StartupPath & "\" & "CustMonthly.rpt"   ' I saved my report in the "\BIN\Debug" dir


Dim strPath As String

Dim strFileName As String

'Filename made up of customer number, year, month

strFileName = strCust & "_" & intYear.ToString & "_" & intMonthStart.ToString

'Path to save pdf report to and filename saved as

strPath = Application.StartupPath & "\reports\" & strFileName & ".pdf"

customerReport.ExportToDisk(ExportFormatType.PortableDocFormat, strPath)


and my code is 

szCurrDir = CurDir.ToString

            'In Class

            Dim customerReport As ReportDocument

            customerReport = New ReportDocument()

            Dim reportPath As String = szCurrDir & "\Other Report\repRD_Excel_Genrat.rpt"   ' I saved my report in the "\BIN\Debug" dir


            Dim strPath As String

            Dim strFileName As String

            'Filename made up of customer number, year, month

            strFileName = "Try"

            'Path to save pdf report to and filename saved as

            strPath = szCurrDir & strFileName & ".pdf"

            customerReport.ExportToDisk(ExportFormatType.PortableDocFormat, strPath)



Error is................ Missing parameter values.

plz help me anyone..............plz





Hi ,

I need to migrate this code from vb 6 to vb.net . There are lables like Errorhandler:, cleanUpObjects:, etc.  Below is my code. its not complete as the original code is very lengthy and complex.

OnErrorGoTo errorhandler

        'Declare Variables,objects



        'Set Error Varable to an Empty String

        m_iErrorNum = 0

        m_sErrorDesc = ""


        *****Some code here ******



        If results < 0 Then

            m_iErrorNum = results

            m_sErrorDesc = Err.Description

            GoTo errorhandler



        'Checking for ErrorCode

        If m_iErrorNum = 0 Then

            LogMsg(sLogPath, " Save XML", CShort(System.Diagnostics.TraceEventType.Information))


           ****Some code here*****


            GoTo cleanUpObjects


        Else m_iErrorNum = 100 Then

            LogMsg(sLogPath, "Setting Custom ERROR XML", CShort(System.Diagnostics.TraceEventType.Information))


            *****Some Code here*****


           GoTo cleanUpObjects

        End If



        'Destroy objects

        OnError ResumeNext

        objRs = Nothing

        strOutput = Nothing

        arrayResult = Nothing




        ****Error Handeling Code****


        GoTo cleanUpObjects

 I want to remove the OnError code and put the Try- catch -Blocks . How can I achive this.

I will appreciate any help .

Thanks in advance.


I have a problem with IE 8 on a computer with SO windows 7 when make a window.open of main page and this load a new page with a pdf file IE responds with the following error in event viewer and automatically closes.
Application popup: Windows - Application Error: The instruction at 0x00000014 referenced memory at 0x77b7fc47. The memory could not be written.
Windows - Application Error
The instruction at 0x00000014 referenced memory at 0x77b7fc47. The memory could not be written. Click on OK to terminate the program

The application code is as follows
Response.ContentType = "Application/pdf";
Response.AppendHeader ( "content-disposition", "attachment; filename =" + filename);
Response.WriteFile (pathPdf);
Response.End ();

This same code works when the response is performed in the same window.

Thank you for your valuable help


Hey guys!

I'm opening a file using Process in VB.Net. But, for some file types, the "Open File - Security Warning" opens.

How can I prevent errors when user click on Cancel button from that dialog? The message error is "The operation was canceled by the user".

The code is above:

'# Opens selected filePrivateSub dgvDocumentos_DoubleClick(ByVal sender AsObject, ByVal e As System.EventArgs) Handles dgvDocumentos.DoubleClick

    Dim lproProcesso AsNew System.Diagnostics.Process
    Dim lpsiProcesso AsNew System.Diagnostics.ProcessStartInfo

    TryIf dgvDocumentos.Rows(dgvDocumentos.CurrentRow.Index).Cells("STATUS").Value <> 1 ThenExitSub

      lpsiProcesso.FileName = dgvDocumentos.Rows(dgvDocumentos.CurrentRow.Index).Cells("FILEPATH").Value

      lproProcesso.StartInfo = lpsiProcesso

    Catch ex As Exception

      MessageBox.Show("Open file - Treatment:" & Chr(13) & ex.Message, "SYSTEM", MessageBoxButtons.OK, MessageBoxIcon.Error)

    FinallyIfNot lproProcesso IsNothingThen

      lproProcesso = Nothing
      lpsiProcesso = NothingEndTryEndSub



how to open a file from the Resources in vb.net i added it i just want to run it (word doc)



To open a pdf file in my vb.net application I have Used the follwing code...

This is working fine while running from code. But when I am trying to package it through setup project and run in the installed application, file not getting opened. I am adding my UserGuide.pdf file inside Database folder in Application folder of setup project.

Can any one help me out on why this is happening...




Dim lStrHelpUserManualPath AsString = ""

lStrHelpUserManualPath = Application.StartupPath


IfNot IO.Directory.Exists(lStrHelpUserManualPath) Then





lStrHelpUserManualPath = lStrHelpUserManualPath &


lStrHelpUserManualPath = lStrHelpUserManualPath &




If IO.File.Exists(lStrHelpUserManualPath) Then





Catch ex As Exception






I am having a problem with Windows 7, where I delete an xml-file in the programData folder using Windows Explorer  (C:\ProgramData\...\Documents\data.xml).

The file is removed in windows explorer, but when running my program, the file is still found, and read.

I tried to restart the pc, but the file is still found by my program.

I recently moved to Windows 7 from Vista, and everything worked fine on Vista. Anybody knows what the problem is?



localDs AsNew DataSet()


' load xml into dataset


If System.IO.File.Exists(dataFile) = TrueThen










I want to hide the rows with null. Thats no problem. I use:


I have no problems in the browser, but if I convert to PDF the browser shows me a mistake. Without the hide-expression I have no problems to export to PDF.

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->



 <customErrors mode="Off"/>



Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->



 <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>



Server Error in '/Reports' Application.
Runtime Error




My program uses the WebBrowser control (.Net Windows Forms) and I proffer (IProfferService) an IDownloadManager implementation to silently handle file downloads. Generally this is working well, but I have a problem when I navigate to a pdf url (eg http://www.w3.org/Protocols/HTTP/1.1/rfc2616.pdf) AND I have Acrobat Reader installed (v 9.3.4). In this case my download manager is not called and the pdf file is opened in Acrobat Reader. (Interestingly, once the file is open in Acrobat a subsequent navigate to the same url will cause my download mananger to be called.) If I uninstall Acrobat Reader then my download manager is called normally. It works well for other non-mshtml file types - docx, avi, ... - my download manager is called and no external program is opened. (I have MS Office, Media Player installed.)

My goal is to be able to manage the downloads myself with no external program activation. Can anyone help me understand why I'm getting this behaviour with Acrobat Reader and how I could circumvent it?

(For info, I've also tried with the csexwb2 sample, DemoApp, and reproduced the same behaviour - pdf files did not appear in the Downloads window.)



Windows 2008 Server R2 x64
Visual Studio 2008
.Net 3.5


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure