Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006
    Posts
    2

    Unanswered: Inserting OLE Object from file

    I'm sure that the answer is obvious once I see it. But, I'm drawing a blank.

    task:
    double click on button/box and have access open the folder to select the file that is to be an ole link (by Icon) to the button/box.

    I used the following [Event Procedure] to open the dialog box where one can start selecting options to drill down to the file.

    DoCmd.RunCommand (acCmdInsertObject)

    How do I preselect the fields "Create from File" and "Link" with the "browes" button selected so that it opens a particular folder?

    Or is there a better way of doing this in general.

    Thank you for your time and assistance.
    PatD.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Simply put....Don't use the

    DoCmd.RunCommand acCmdInsertObject

    Its intent is to simply bring up the Insert Object dialog box which by the look of it, is not what you want anyway. So don't use it. Use some other means to display a File Dialog box (many samples in this forum) then pop the item selected into the OLEBound control.

    I personally prefer to use API functions for providing File Dialog boxes to users due to the enormous flexability available (also somewhere in this forum). You can then use code like this to load your OLE Bound control:

    If you want to Embed then use:
    Code:
    Dim OLEFileName As String
    OLEFileName = MyBrowsForFileFunction("MyStartLocation","MyFilter") ' Or whatever function you prefer.
    If OLEFileName <> "" Then 
       Me.myOLEBoundObjectControl.OLETypeAllowed = acOLEEmbedded
       Me.myOLEBoundObjectControl.SourceDoc = OLEFileName
       Me.myOLEBoundObjectControl.Action = acOLECreateEmbed
    End If
    Me.theControlThatInitiatedThis.SetFocus
    If you want to Link then use:
    Code:
    Dim OLEFileName As String
    OLEFileName = MyBrowsForFileFunction("MyStartLocation","MyFilter") ' Or whatever function you prefer.
    If OLEFileName <> "" Then 
       Me.myOLEBoundObjectControl.OLETypeAllowed = acOLELinked
       Me.myOLEBoundObjectControl.SourceDoc = OLEFileName
       Me.myOLEBoundObjectControl.Action = acOLECreateLink
    End If
    Me.theControlThatInitiatedThis.SetFocus
    Hmmm....path-n-file names from table

    Hope this helps.

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    May 2006
    Posts
    2

    Inserting OLE Object from file

    Thank you for the information. It is helpful and pointed me in another directions.
    PatD.

Posting Permissions

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