Hi Tommy this looks very nice!Originally Posted by Tommy
Well done!
But no this won't run in 97 have a minute and I'll set it up for 97 to complete it!
Hi Tommy this looks very nice!Originally Posted by Tommy
Well done!
But no this won't run in 97 have a minute and I'll set it up for 97 to complete it!
_________
Groetjes,
Joost Verdaasdonk
M.O.S. Master
Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
(I don't answer questions asked through E-mail or PM's)
Hi Tommy,
Ok minor change in OpenSelectedFiles:
arrFls needs to be a variant the way it is used so change to:
[vba]
Dim arrFls As Variant
[/vba]
Further more Split is not supported in 97 it's supported >2000.
So add a custom one like:[VBA]
Public Function Split(Expression As String, Optional ByVal Delimiter As _
String = " ", Optional ByVal Count As Long = -1, _
Optional ByVal Compare As Integer = 0) As Variant
Dim lPos1 As Long
Dim lPos2 As Long
Dim lIdx As Long
Dim lCnt As Long
Dim arResult() As String
'Initialize the variables
lCnt = 0
lPos1 = 1
ReDim arResult(99)
'Search for the delimiter.
lPos2 = InStr(1, Expression, Delimiter, Compare)
Do While lPos2 > 0 And ((lCnt <= Count) Or (Count = -1))
'Delimiter found, extract the substring between the delimiters.
arResult(lCnt) = Mid$(Expression, lPos1, lPos2 - lPos1)
lCnt = lCnt + 1
If (lCnt Mod 100) = 0 Then
'Increase array size if needed.
ReDim Preserve arResult(UBound(arResult) + 100)
End If
'Move to end of last delimiter found.
lPos1 = lPos2 + Len(Delimiter)
'Search for the next delimiter.
lPos2 = InStr(lPos1, Expression, Delimiter, Compare)
Loop
If lPos1 < Len(Expression) Then
'Extract last substring.
arResult(lCnt) = Mid$(Expression, lPos1)
lCnt = lCnt + 1
End If
'Resize the array to correct size.
If lCnt > 0 Then
ReDim Preserve arResult(lCnt - 1)
Else
ReDim arResult(-1 To -1)
End If
'Return the array.
Split = arResult
End Function
[/VBA]
I'll attach my testdoc voor dcrane to have a go with it.
Later buddy!
_________
Groetjes,
Joost Verdaasdonk
M.O.S. Master
Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
(I don't answer questions asked through E-mail or PM's)
OK, good deal, I am very interested in the differences be nice to add it to my "arsenal"
I saw the post as I typed this LOL the Split of course I would have never thought to check the length of the delimiter. You passed a variant instead of an array of strings, Sweet , that would have been a nail biter
Hi Tommy,
I found me another problem!
The code as it stands works well on multiple selections but not on a single selection! (At least not over here) (The API returnes full path as 0 array when only one file is selected...)
I've made the folowing adjustment to cater for only one item in selectedfiles:[VBA]
Public Function OpenSelectedFiles(iFileList As String)
Dim CPath As String 'path string
Dim mI As Long
Dim arrFls As Variant
'get directory with files
arrFls = Split(iFileList, Chr(0))
'get directory
CPath = arrFls(0)
If Dir(CPath) <> "" Then
Application.Documents.Open Trim$(arrFls(0))
ElseIf Right$(CPath, 1) <> "\" Then
CPath = CPath & "\"
'for each file show a message box
For mI = 1 To UBound(arrFls)
If arrFls(mI) <> vbNullString Then _
Application.Documents.Open CPath & "\" & Trim$(arrFls(mI))
Next
End If
End Function
[/VBA]
Can you test if it works well for you as well?
_________
Groetjes,
Joost Verdaasdonk
M.O.S. Master
Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
(I don't answer questions asked through E-mail or PM's)
Works in 2000 and 2003. Good catch . I thought I had that one taken care of.
LOL I guess I need to post a warning message about Brain Cramps
Well then we've covered all versions of Word for this one!Originally Posted by Tommy
And for the Brain Cramps......I always forget a lot of stuff...o Well!
_________
Groetjes,
Joost Verdaasdonk
M.O.S. Master
Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
(I don't answer questions asked through E-mail or PM's)
Tommy,
Thanks for the code. I cannot compile it with Word 97. I error out on the line
arrFls = Split(iFileList, Chr(0)) . It doesn't like Split. I commented out the line and it compiled OK but no Open box ever appears. I did a F1 help for Split and in Word97
and this is the example they give for the 97 Split Property.
This example splits the active window into two equal-sized window panes.
ActiveWindow.Split = True
If the Document1 window is split, this example closes the active pane.
If Windows("Document1").Split = True Then
Windows("Document1").ActivePane.Close
End If
Dave
dcrane37 right click on the "Tommy 97 (2).zip" posted by MOS Master. That was fixed, along with another problem we found.
Let me know if you need more help.
Hi Dave,Originally Posted by dcrane37
Like Tommy said the 97 problems should be fixed in that attachments code but I wonder what the quoted code has to do with your question?
That Split Method is something entirely different then the Split Function.
_________
Groetjes,
Joost Verdaasdonk
M.O.S. Master
Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
(I don't answer questions asked through E-mail or PM's)