Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Unanswered: VBA Paste Command

    What would be the vba command to paste an image object from the clipboard into a OLE object field?
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    no not a good move the database will blot heaps

    What i do is just store the filename and use the


    in the current event

    Code:
    Private Sub Form_Current()
    Me.ShowImage.Picture = ThisFolder & "\" & Me.PhotoName
    End Sub
    ThisFolder is a Const I setup
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I do have an option to store the filename and have a very good routine which opens/saves the filename (my routine will actually recognize ANY file saved and open the associated application for that file extension). But in this situation, the user wants the actual picture stored as well. These are NOT Access tables - they are linked SQL Server tables. If it were Access tables, I would not give the option to store images (as I know about bloating issues). I just need the command to copy the image from the clipboard to the OLE object. I already realize the bloating problem but this is not a concern here.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Myle,

    Thanks though for your reply. FYI: here's a very good routine to opening the filename which I mentioned I already have (like I mentioned - this routine works almost flawlessly). But I do need the vba code to copy a clipboard image to an OLE Object field.

    Function OpenProgram(PType As String, FN As String)
    DoCmd.OpenForm "StandBy"
    Forms!Standby!LblCaption.Caption = "Stand By - Opening File: " & strFileName
    Dim strFN As String
    strFN = GetNamePart(FN)
    On Error GoTo DD
    Select Case PType
    Case "doc"
    On Error GoTo DD
    Call Shell("WINWORD.exe " & Chr(34) & FN & Chr(34), vbMaximizedFocus)
    Exit Function
    Case "xls", "csv"
    On Error GoTo DD
    Call Shell("Excel.exe " & Chr(34) & FN & Chr(34), vbMaximizedFocus)
    Exit Function
    Case "BMP", "JPG"
    On Error GoTo DD
    Call Shell("MSPaint.exe " & Chr(34) & FN & Chr(34), vbMaximizedFocus)
    Exit Function
    Case "txt"
    On Error GoTo DD
    Call Shell("Notepad.exe " & Chr(34) & FN & Chr(34), vbMaximizedFocus)
    Exit Function
    End Select
    DD:
    ' On Error GoTo Dend
    On Error GoTo D2
    Call fHandleFile(strFN, WIN_NORMAL)
    ' LUName = PN & " " & Chr(34) & FN & Chr(34)
    Exit Function
    D2:
    On Error GoTo Dend
    Dim PN As Variant
    PN = InputBox("Still could not load this file type. The file could already be open or the application to open this file could not be found. Please type in the program name (i.e. executable application name such as MSWord or Excel) to load this file and I'll attempt to load the file again:")
    Call Shell("" & PN & "" & Chr(34) & FN & Chr(34), vbMaximizedFocus)
    ' Call Shell(" & command.com /c " & PN & "" & Chr(34) & FN & Chr(34), vbMaximizedFocus)
    Exit Function
    Dend:
    MsgBox ("Still could not load file: " & FN & ". Contact your dbAdministrator or Network Administrator to locate the program to open this file type.")

    End Function



    Function GetNamePart(strIn As String) As String
    Dim intCounter As Integer
    Dim strTmp As String
    For intCounter = Len(strIn) To 1 Step -1
    If MID$(strIn, intCounter, 1) <> "\" Then
    strTmp = MID$(strIn, intCounter, 1) & strTmp
    Else
    Exit For
    End If
    Next intCounter
    GetNamePart = strTmp
    End Function


    Option Compare Database

    '************ Code Start **********
    ' This code was originally written by Dev Ashish.
    ' It is not to be altered or distributed,
    ' except as part of an application.
    ' You are free to use it in any application,
    ' provided the copyright notice is left unchanged.
    '
    ' Code Courtesy of
    ' Dev Ashish
    '
    Private Declare Function apiShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" _
    (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) _
    As Long

    '***App Window Constants***
    Public Const WIN_NORMAL = 1 'Open Normal
    Public Const WIN_MAX = 3 'Open Maximized
    Public Const WIN_MIN = 2 'Open Minimized

    '***Error Codes***
    Private Const ERROR_SUCCESS = 32&
    Private Const ERROR_NO_ASSOC = 31&
    Private Const ERROR_OUT_OF_MEM = 0&
    Private Const ERROR_FILE_NOT_FOUND = 2&
    Private Const ERROR_PATH_NOT_FOUND = 3&
    Private Const ERROR_BAD_FORMAT = 11&

    '***************Usage Examples***********************
    'Open a folder: ?fHandleFile("C:\TEMP\",WIN_NORMAL)
    'Call Email app: ?fHandleFile("mailto:dash10@hotmail.com",WIN_NORMA L)
    'Open URL: ?fHandleFile("http://home.att.net/~dashish", WIN_NORMAL)
    'Handle Unknown extensions (call Open With Dialog):
    ' ?fHandleFile("C:\TEMP\TestThis",Win_Normal)
    'Start Access instance:
    ' ?fHandleFile("I:\mdbs\CodeNStuff.mdb", Win_NORMAL)
    '************************************************* ***

    Function fHandleFile(stFile As String, lShowHow As Long)
    Dim lRet As Long, varTaskID As Variant
    Dim stRet As String
    'First try ShellExecute
    lRet = apiShellExecute(hWndAccessApp, vbNullString, _
    stFile, vbNullString, vbNullString, lShowHow)

    If lRet > ERROR_SUCCESS Then
    stRet = vbNullString
    lRet = -1
    Else
    Select Case lRet
    Case ERROR_NO_ASSOC:
    'Try the OpenWith dialog
    varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
    & stFile, WIN_NORMAL)
    lRet = (varTaskID <> 0)
    Case ERROR_OUT_OF_MEM:
    stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
    Case ERROR_FILE_NOT_FOUND:
    stRet = "Error: File not found. Couldn't Execute!"
    Case ERROR_PATH_NOT_FOUND:
    stRet = "Error: Path not found. Couldn't Execute!"
    Case ERROR_BAD_FORMAT:
    stRet = "Error: Bad File Format. Couldn't Execute!"
    Case Else:
    End Select
    End If
    fHandleFile = lRet & _
    IIf(stRet = "", vbNullString, ", " & stRet)
    End Function
    '************ Code End **********
    Last edited by pkstormy; 11-30-06 at 17:34.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •