opening an image viewer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shumit Rehman

    opening an image viewer

    Hi

    I have a table which has path names to photos I would like to view. I
    would like to open some/any kind of image viewer(Paint) to see the
    picture when I click the pathname.

    The pictures are mostly scanned newspaper atricles which are too big
    to just display on a form so I need the zoom and scroll features.

    Im using access 2003

    thanks in anticipation
    Shumit
  • Larry  Linson

    #2
    Re: opening an image viewer

    See help for the Shell statement... that will open another program, and you
    can specify "command line parameters", too, so you should be able to open an
    image processing program on the file whose path and filename you have
    stored.

    Larry Linson
    Microsoft Access MVP

    "Shumit Rehman" <shumitrehman@h otmail.com> wrote in message
    news:3a2b6094.0 408010649.6be5f e3b@posting.goo gle.com...[color=blue]
    > Hi
    >
    > I have a table which has path names to photos I would like to view. I
    > would like to open some/any kind of image viewer(Paint) to see the
    > picture when I click the pathname.
    >
    > The pictures are mostly scanned newspaper atricles which are too big
    > to just display on a form so I need the zoom and scroll features.
    >
    > Im using access 2003
    >
    > thanks in anticipation
    > Shumit[/color]


    Comment

    • Don Leverton

      #3
      Re: opening an image viewer

      Hi Shumit,

      How about this idea?:

      1.) Modify your table so that you store your FilePath string as a Hyperlink.
      2.) Design a form based on this modified table
      3.) Add an Image Control (Size Mode = Zoom) on this form that will allow you
      to "preview" the image as you navigate from record to record.
      4.) The file path for the hyperlink could be set using Dev's FileOpenSave
      Common Dialog API http://www.mvps.org/access/api/api0001.htm
      5.) The hyperlink can be used "dual purpose"...
      Clicking on it will open the image in the default viewer assigned for files
      of that type,
      and if we trim out the "#" signs, it can also be used to set the .Picture
      property of the Image control.

      If this sounds good, here is the code that you'll need...

      *************** *** Main Module (DB Window) Code *************** ***
      -- I'd suggest pasting this code into the same module as the FileOpenSave
      API

      '------------------------------------------------------
      Function GetGraphic()
      ' Requires FileOpenSave API code
      ' from http://www.mvps.org/access/api/api0001.htm

      Dim strFilter As String

      strFilter = ahtAddFilterIte m(strFilter, "TIFF Files (*.tif, *.tiff)",
      "*.TIF; *.TIFF")
      strFilter = ahtAddFilterIte m(strFilter, "JPEG Files (*.jpg, *.jpeg)",
      "*.JPG; *.JPEG")
      strFilter = ahtAddFilterIte m(strFilter, "GIF Files (*.gif)", "*.GIF")
      strFilter = ahtAddFilterIte m(strFilter, "WMF Files (*.wmf)", "*.WMF")
      strFilter = ahtAddFilterIte m(strFilter, "All Files (*.*)", "*.*")
      'You could add more file formats using the pattern above.

      GetGraphic = ahtCommonFileOp enSave(InitialD ir:="C:\", _
      Filter:=strFilt er, FilterIndex:=1, _
      DialogTitle:="S elect Graphic File to Import")

      End Function

      '------------------------------------------------------
      Function StripChar(MyStr As String, RemoveChar As String) As Variant
      On Error GoTo StripCharError

      Dim strChar As String, strHoldString As String
      Dim i As Integer

      ' Exit if the passed value is null.
      If IsNull(MyStr) Then Exit Function

      ' Exit if the passed value is not a string.

      If VarType(MyStr) <> 8 Then Exit Function

      ' Check each value for invalid characters.
      For i = 1 To Len(MyStr)
      strChar = Mid$(MyStr, i, 1)
      If strChar = RemoveChar Then
      ' Do nothing
      Else
      strHoldString = strHoldString & strChar
      End If
      Next i

      ' Pass back corrected string.
      StripChar = strHoldString

      StripCharEnd:
      Exit Function

      StripCharError:
      MsgBox Error$
      Resume StripCharEnd
      End Function

      *************** ***** Form (Class) Module Code *************** ******

      Option Compare Database
      Option Explicit

      '------------------------------------------------------
      Private Sub cmdImportFileNa mes_Click()
      On Error GoTo Err_cmdImportFi leNames_Click

      Dim strFile As String
      strFile = GetGraphic 'Call the function

      Me![FilePath] = "#" & strFile & "#" ' The pound signs are required by the
      hyperlink

      Me![ctlImageFrame].Picture = StripChar(Me![FilePath], "#") 'But the pound
      signs mess up the .Picture :(
      Me.Refresh

      Exit_cmdImportF ileNames_Click:
      Exit Sub

      Err_cmdImportFi leNames_Click:
      MsgBox Err.Description
      Resume Exit_cmdImportF ileNames_Click

      End Sub
      '------------------------------------------------------

      Private Sub Form_Current()
      On Error Resume Next

      If IsNull(Me![FilePath]) Then
      Me![ctlImageFrame].Picture = "C:\Art\CAMERA. TIF" 'I use this to indicate
      that no picture is available
      Else
      Me![ctlImageFrame].Picture = StripChar(Me![FilePath], "#") 'Remove the
      pound signs, which mess up the .Picture
      End If

      End Sub
      *************** *************** *************** ***************


      "Shumit Rehman" <shumitrehman@h otmail.com> wrote in message
      news:3a2b6094.0 408010649.6be5f e3b@posting.goo gle.com...[color=blue]
      > Hi
      >
      > I have a table which has path names to photos I would like to view. I
      > would like to open some/any kind of image viewer(Paint) to see the
      > picture when I click the pathname.
      >
      > The pictures are mostly scanned newspaper atricles which are too big
      > to just display on a form so I need the zoom and scroll features.
      >
      > Im using access 2003
      >
      > thanks in anticipation
      > Shumit[/color]


      Comment

      • Stephen Lebans

        #4
        Re: opening an image viewer

        You can easily achieve Zoom/Scroll for your Images within the standard
        Access GUI.
        See:


        --

        HTH
        Stephen Lebans

        Access Code, Tips and Tricks
        Please respond only to the newsgroups so everyone can benefit.


        "Shumit Rehman" <shumitrehman@h otmail.com> wrote in message
        news:3a2b6094.0 408010649.6be5f e3b@posting.goo gle.com...[color=blue]
        > Hi
        >
        > I have a table which has path names to photos I would like to view. I
        > would like to open some/any kind of image viewer(Paint) to see the
        > picture when I click the pathname.
        >
        > The pictures are mostly scanned newspaper atricles which are too big
        > to just display on a form so I need the zoom and scroll features.
        >
        > Im using access 2003
        >
        > thanks in anticipation
        > Shumit[/color]

        Comment

        • Shumit Rehman

          #5
          Re: opening an image viewer

          Wow - three different ways. I'll try all three.

          thanks.
          Shumit

          Comment

          Working...