inserting active X on a form

vish

New member
Local time
Today, 03:58
Joined
Jan 31, 2002
Messages
7
when i try to insert microsoft common dialog control, version 6.0, i am getting an error "MS OLE Server isn't registered" to register it reinstall it.
what should i do?
 
You do not always get a licence to use the common dialog control with your copy of Access. You can try to install another application that will contain this licence. I used VB for this or you could try search this site. I know this question has been answered before.

Alternatively could try putting this code into a common module and calling it from your form.... I must appologize in that I have lost the document that tells me who to credit this code to.

Function GetPath(strform As Form, init_path As String, msg As String) As String

Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String

OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
sFilter = "Microsoft Excel Files (*.XLS)" & Chr(0) & "*.XLS" & Chr(0) _
& "All Files (*.*)" & Chr(0) & "*.*" & Chr(0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = init_path
OpenFile.lpstrTitle = msg
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)

If lReturn = 0 Then
MsgBox "A file was not selected!", vbInformation, _
msg
Else
GetPath = Trim(OpenFile.lpstrFile)
End If

End Function

I also call this function to clean the returned path to a useable format...

Public Function Strip(strPath As String) As String

Dim i As Integer
Dim j As Integer

For i = 1 To Len(strPath)
If Asc(Mid(strPath, i, 1)) = 0 Then
Strip = Left(strPath, i - 1)
i = Len(strPath)
End If
Next i

End Function

Then these two just to get the file name from the path


Public Function reverse(yourstring As String)

Dim MyLoop As Integer

For MyLoop = Len(yourstring) To 1 Step -1
reverse = reverse & Mid(yourstring, MyLoop, 1)
Next MyLoop

End Function

Public Function get_file_name(FilePath As String) As String

Dim temp As String
Dim i As Integer
Dim counter As Long

counter = Len(FilePath)
temp = reverse(FilePath)

For i = 1 To counter
If Mid(temp, i, 1) = "\" Then
temp = Mid(temp, 1, i - 1)
i = counter
End If
Next i

get_file_name = reverse(temp)


End Function

I'll bet someone else has a better way to do this, but this one does work
HTH
Chris
 

Users who are viewing this thread

Back
Top Bottom