Late Binding Question???

  • Thread starter Thread starter Pete
  • Start date Start date
P

Pete

I want to eliminate the binding of the Microsoft Office Object. I have
located the primary offender, FileDialog, in my code. However, I
cannot find what office app I should use.

If I use a word document or should I use something like
Office.application????
 
To free yourself from this ghastly object, use the API call in this link
instead:
http://www.mvps.org/access/api/api0001.htm

FileDialog has many limitations and issues - not only the reference and
versioning problems, but the SaveAs option it seems to offer doesn't work at
all in Access.
 
How do you get this code to allow the selection of only a
directory/subdirectory?
 
Something you must do (plus I need to remember to give Arvin an update to
that page, as this is a fairly common issue!)

When you use Multi-Select, the string that's returned contains the name of
the folder, followed by a Null character (Chr(0)), followed by the name of
the first file, followed by a Null character, followed by the name of the
second file, followed by a Null character, followed by the name of the next
file and so on until all file names have been returned. There will actually
be two Null characters at the end of the string.

Unfortunately, the TrimNull function in that sample page is set up to trim
at the first Null, so all it's going to return is the folder.

Change that function so something like:

Private Function TrimNull(ByVal strItem As String) As String
Dim intPos As Integer
intPos = InStr(strItem, vbNullChar & vbNullChar)
If intPos > 0 Then
TrimNull = Left(strItem, intPos - 1)
Else
intPos = InStr(strItem, vbNullChar & vbNullChar)
If intPos > 0 Then
TrimNull = Left(strItem, intPos - 1)
Else
TrimNull = strItem
End If
End If
End Function

Then, you'll need to add logic to parse what's returned as the string.

Assuming you're using Access 2000 or newer, the simplest is something like:


Dim intLoop As Integer
Dim strFiles As String
Dim varFiles As Variant

strFiles = ahtCommonFileOpenSave(....)

If Len(strFiles) > 0 Then
varFiles = Split(strItem, Chr(0))
For intLoop = 1 To UBound(varFiles)
Debug.Print "File " & intLoop & ": " & _
varFiles(0) & "\" & varFiles(intLoop)
Next intLoop
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top