상세 컨텐츠

본문 제목

Create Pdf File From Vb6 Msgbox

카테고리 없음

by edalnige1988 2020. 2. 23. 16:51

본문

Hi,I want to convert my word file to pdf file in vb6.source code will be appreciated.so far, i have tried with below code also. Private Sub ConvertWordDoctoPDF(DocPath As String, sDestsPDFFile As String)'Dim worddoc As New Word.ApplicationDim worddoc As ObjectSet worddoc = CreateObject('Word.Application')Dim x As StringDim doc As DocumentOn Error GoTo Errhndx = DocPathSet doc = worddoc.Documents.Open(x) '-open the docx'now docx file is already open.

Vb6

Hello All,I got the solution. Please find below code to convert word file to pdf file.

This code shows how to open a pdf in adobe reader. The pdf is installed in the application folder along with the program.Private Sub PDFManualToolStripMenuItemClick(sender As System.Object, e As System.EventArgs) Handles PDFManualToolStripMenuItem.ClickDim NewName As String = StartupDir$ + 'Cadrail Manual.pdf'If File.Exists(NewName) ThenSystem.Diagnostics.Process.Start(NewName)ElseMsgBox('Cadrail cannot find the file: ' + Chr(13) + Chr(13) + NewName + Chr(13) + Chr(13) + 'The file may have been moved.' , 48, 'Open Manual PDF')End IfEnd SubPS Here is how to get the program folder: StartupDir$ = System.Windows.Forms.Application.StartupPath. I've not used Solution Explorer for that but I suppose that method may work.Typically I select the Project tab and at the bottom select the applications properties menu item. In the applications properties window I select Resources, then in the add dropdown I select Add from existing file. Then browse to the file and add it.

Thenbuild the app and it becomes part of the applications executable file.Then it is available from My.Resources.However to display it I use the Adobe Acrobat Reader ActiveX control that comes with Adobe Acrobat Reader. So if you have a current version of Adobe Acrobat Reader installed on your system you can use that control to display the.PDF.But the ActiveX control can only load from a File. So you need to write the resource to a File prior to loading it.

You can get a temporary file name to use for that. Write the resource to the temp file then have the ActiveX load it. This code shows how to open a pdf in adobe reader. The pdf is installed in the application folder along with the program.Private Sub PDFManualToolStripMenuItemClick(sender As System.Object, e As System.EventArgs) Handles PDFManualToolStripMenuItem.ClickDim NewName As String = StartupDir$ + 'Cadrail Manual.pdf'If File.Exists(NewName) ThenSystem.Diagnostics.Process.Start(NewName)ElseMsgBox('Cadrail cannot find the file: ' + Chr(13) + Chr(13) + NewName + Chr(13) + Chr(13) + 'The file may have been moved.' , 48, 'Open Manual PDF')End IfEnd SubPS Here is how to get the program folder: StartupDir$ = System.Windows.Forms.Application.StartupPath.

I've not used Solution Explorer for that but I suppose that method may work.Typically I select the Project tab and at the bottom select the applications properties menu item. In the applications properties window I select Resources, then in the add dropdown I select Add from existing file. Then browse to the file and add it. Thenbuild the app and it becomes part of the applications executable file.Then it is available from My.Resources.However to display it I use the Adobe Acrobat Reader ActiveX control that comes with Adobe Acrobat Reader.

So if you have a current version of Adobe Acrobat Reader installed on your system you can use that control to display the.PDF.But the ActiveX control can only load from a File. So you need to write the resource to a File prior to loading it. You can get a temporary file name to use for that. Write the resource to the temp file then have the ActiveX load it.

Thanks for that. I am trying to avoid OpenFileDialog. That is one reason I copied the pdf to the Solution Explorer but not sure how to reference it. I have Adobe PDF Reader added in the toolbox. I was wondering if I can use something likeAxAcroPDF1.src to reference the pdf in the Solution Explore but as I am new to Visual Basic, I find it difficult to understand how to do it.I believe I explained in my post how I did it. And I believe I mentioned the code in Button2 click sub and not the code in Button1 click sub.If you re-read my post which part can you not understand?La vida loca.

Thanks for that. I am trying to avoid OpenFileDialog. That is one reason I copied the pdf to the Solution Explorer but not sure how to reference it. I have Adobe PDF Reader added in the toolbox. I was wondering if I can use something likeAxAcroPDF1.src to reference the pdf in the Solution Explore but as I am new to Visual Basic, I find it difficult to understand how to do it.I see. Well sorry it is just pieces of code that have to be assembled. I made a full working example below.Perhaps you should explain what your overall goal is in more detail.

Why do you want to show a pdf file? Why solution explorer?If something is not declared then you should declare it.:) Just look up how to do that. Part of learning to program is learning to use the instructions and solve problems.I guess I threw a bit of a curve with StartupDir$ you dont need the$ that is old. Just declare it a string.dim mypath as string.Its just a string that is the path to the file. This path is defined by where you application.exe is running from:System.Windows.Forms.Application.StartupPathYou ask windows for the folder path to your exe.

You put the pdf in that folder.You don't event need that string as I show in the example.As far as file.exits goes, you need to add a reference for it. If you put Option Strict On as the first line of code in the project form it will flag errors. See where I added Option Strict below. And now there is a red line under file. Put the mouse pointerover the red line and the error message will pop up. On the msg is show suggestions click that:after clicking a new popup with the suggestions.

At the top is add File.IO click that:and the designer will add it to the top of your form as in the example. I also just removed theStartupDir$ variable. So you should be able to change the file name you yours and put the pdf in you bindebug folder and it will find it. Or hardcode in a path to your file just to test the rest of the code.Option Strict OnImports System.IOPublic Class Form3Private Sub Button1Click(sender As Object, e As EventArgs) Handles Button1.ClickDim NewName As String = System.Windows.Forms.Application.StartupPath + 'MyFile.pdf'If File.Exists(NewName) ThenSystem.Diagnostics.Process.Start(NewName)ElseMsgBox('Cadrail cannot find the file: ' + Chr(13) + Chr(13) + NewName + Chr(13) + Chr(13) + 'The file may have been moved.' , MsgBoxStyle.OkOnly, 'Open Manual PDF')End IfEnd SubEnd ClassPS All of these things are complicated and complex. You have learning to do. Take each one step at a time.

Data Report In Vb6 Tutorial Pdf

Get it working and understood then move to the next. Use the instructions. Then come back. Well sorry it is just pieces of code that have to be assembled. I made a full working example below.Perhaps you should explain what your overall goal is in more detail. Why do you want to show a pdf file? Why solution explorer?The confusion was created by StartupDir$.

Vba Msgbox Options

I thought it must be a reserved a special keyword and I was trying to resolve it. It didn't occur to me it was just something I had to declare. Everything is sorted now and it is working.

Create Pdf File From Vb6 Msgbox To Show

The only change I hadto do was to add a ' in front of 'MyFile.pdf'My application captures user information using Windows Forms and writes to a table in a SQL database. The user can also change or delete records. I have completed all that. Then I wrote the user guide and was thinking of an easy way the user can access it.With my limited knowledge on VB, I thought if I have the user guide in the solution explorer, then it will get compiled with the code so that I don't have to keep it in a folder. I don't know if this is feasible so I wanted to try that.I couldn't think of a better or easier way to include the User Guide. I thought of creating a.chm file and attach it to the Help button.

But felt it was old fashioned. Couldn't bother to create new form for the user guide because every time I change theuser guide, then I will have to change the form. That's why I thought of an easier way came up with having the pdf in the solution explorer.Thanks for your help.