Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OLE Question

Status
Not open for further replies.

Qwert0000

Technical User
Oct 24, 2003
30
0
0
Howdy,

I have a bound OLE object on a form that holds a jpeg. I am able to inset a file into this form using the inset object menu browse ect.

I would like to add a cmd button that opens the file dialog and allows me to choose the file I want and inserts that file into the ole object.

I have managed to get the file dialog open but cant seem to find the write command to inset the selected file.

I have this code so far

With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.FilterIndex = 2
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path & "/Pics"

my ole object is OLEPicture

and i have been playing with Action acOLECreateEmbed
but I really have no clue what I'm doing.

Any help you would greatly appreciated. Thanks to all who contrubite to this site. I have learned so much just reading every ones posts.
 
I managed to get the code working with help from the northwinds DB and a post on another board.

When I embed a jpeg (my jpegs are all 6k max)the db starts getting very large very fast. The files get embeded as Microsoft Photo Editer 3.0 photo. If i put them in as bmp (50 k files size) the db doesnt seem to swell up as fast
I compact on close and should never have more than 40 - 50 jpgs in the table. I tried just linking the files vice embeding them, but I was getting a flash on the screen every I moved to the next record time showing the Importing Object dialog. Found it to be quite annoying and on occasion if I was navigating through records too fast the "Import box" would freeze on the screen. Have to CNT/alt/Delete end task to make the box go away.

Any thoughts?

Keep in mind I am a novice.

TIA

My code is as follows


Private Sub CmdAddPicture_Click()
On Error GoTo Error_CmdAddPicture_Click
Dim FileLocation As Variant

FileLocation = getFileName

If Not IsNull(FileLocation) Then
showImageFrame
Me.OLEpicframe.Class = ""
Me.OLEpicframe.SourceDoc = FileLocation
Me.OLEpicframe.Action = acOLECreateEmbed
Me.txtSSN.SetFocus
End If


Exit_CmdAddPicture_Click:
Exit Sub
Error_CmdAddPicture_Click:
MsgBox CStr(Err) & " " & Err.Description
Resume Exit_CmdAddPicture_Click


End Sub

Function getFileName()

Dim result As Integer

With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path & "/Pics"
result = .Show
If (result <> 0) Then
getFileName = Trim(.SelectedItems.Item(1))
Else
getFileName = Null
End If
End With
End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top