Author Topic: VBa  (Read 5154 times)

0 Members and 1 Guest are viewing this topic.

krampaul82

  • Newt
  • Posts: 179
VBa
« on: June 07, 2010, 02:17:20 PM »
How do I open a .pdf file from a Visual Basic Program?
any help appreciated...
When i see someone fall, my first instinct is to laugh!
but then i think, wait a minute! they could of fallen on ME!
Mark

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16872
  • Superior Stupidity at its best
Re: VBa
« Reply #1 on: June 07, 2010, 03:18:34 PM »
Open it as open adobe to view it or open it as open it in VBA to do something with it?

Prior is something like this:

Code: [Select]
Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long

Public Function OpenFile(ByVal FileName As String) As Long
   OpenFile = ShellExecute(0, "Open", FileName, "", "C:\", 1)
End Function

latter isn't gonna happen without some knowledge of the PDF structure and/or a type library and/or a class for handling PDF files.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

krampaul82

  • Newt
  • Posts: 179
Re: VBa
« Reply #2 on: June 07, 2010, 03:56:05 PM »
I would like to press a command button and have it open an adobe pdf file for printing
When i see someone fall, my first instinct is to laugh!
but then i think, wait a minute! they could of fallen on ME!
Mark

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16872
  • Superior Stupidity at its best
Re: VBa
« Reply #3 on: June 07, 2010, 04:01:13 PM »
well, that will do it, just pass the file name to the function and it will open the PDF in adobe
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

krampaul82

  • Newt
  • Posts: 179
Re: VBa
« Reply #4 on: June 07, 2010, 04:42:07 PM »
using your example above how would i pass the filename to this function?
(at your convienence.....)
When i see someone fall, my first instinct is to laugh!
but then i think, wait a minute! they could of fallen on ME!
Mark

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16872
  • Superior Stupidity at its best
Re: VBa
« Reply #5 on: June 07, 2010, 04:48:33 PM »
Code: [Select]
OpenFile "filenamegoeshere"

That simple
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

krampaul82

  • Newt
  • Posts: 179
Re: VBa
« Reply #6 on: June 07, 2010, 04:57:56 PM »
Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long

Public Function OpenFile(ByVal FileName As String) As Long

   OpenFile = ShellExecute(0, "Open", FileName, "", "C:\ALL_pdf_Cut_Sheets\Actuators\", 1)
End Function

like this?
sub file_get
OpenFile "ms8105a1008"
End Sub
When i see someone fall, my first instinct is to laugh!
but then i think, wait a minute! they could of fallen on ME!
Mark

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16872
  • Superior Stupidity at its best
Re: VBa
« Reply #7 on: June 07, 2010, 05:41:56 PM »
that should do it, but you might need to include the path to the file as well. All I can suggest it to try it
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

krampaul82

  • Newt
  • Posts: 179
Re: VBa
« Reply #8 on: June 08, 2010, 10:14:26 AM »
No Dice... :|

Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long

Public Function OpenFile(ByVal FileName As String) As Long

   OpenFile = ShellExecute(0, "Open", FileName, "", "C:\ALL_pdf_Cut_Sheets\Actuators\", 1)
End Function

like this?
sub file_get
OpenFile "C:\ALL_pdf_Cut_Sheets\Actuators\ms8105a1008"
End Sub
When i see someone fall, my first instinct is to laugh!
but then i think, wait a minute! they could of fallen on ME!
Mark

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16872
  • Superior Stupidity at its best
Re: VBa
« Reply #9 on: June 08, 2010, 11:22:03 AM »
you need to include the file extension ..

Try this:
Code: [Select]
Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long

Public Function OpenFile(ByVal FileName As String) As Long
   OpenFile = ShellExecute(0, "Open", FileName, "", "C:\ALL_pdf_Cut_Sheets\Actuators\", 1)
End Function

Sub file_get()
   OpenFile "C:\ALL_pdf_Cut_Sheets\Actuators\ms8105a1008.pdf"
End Sub

In your form, make the action of the click event for your button call file_get
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

krampaul82

  • Newt
  • Posts: 179
Re: VBa
« Reply #10 on: June 09, 2010, 09:54:46 AM »
Suh-Wheet that was it. Thanks for sticking with me Keith.
When i see someone fall, my first instinct is to laugh!
but then i think, wait a minute! they could of fallen on ME!
Mark

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16872
  • Superior Stupidity at its best
Re: VBa
« Reply #11 on: June 09, 2010, 09:56:12 AM »
no problem
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

jgr

  • Guest
Re: VBa
« Reply #12 on: June 18, 2010, 08:02:52 PM »
For print Try with verb "print" (parameter lpOperation)

ShellExecute(0, "print",....