Peter
Sun Aug 29 23:30:37 CDT 2004
Hi Al Grant
You need to write you own function. I don't currently have a Word 97 version of Office
installed - so I don't know whether you can write a function like this:
Public Function Spliter(ByVal ToSplit As String, _
ByVal Delimiter As String) As String()
Const ARRAY_INCREMENT As Long = 10
Dim lngPosition As Long
Dim lngLastPosition As Long
Dim lngUsed As Long
Dim astrChunks() As String
' Basic validation
If LenB(ToSplit) = 0 Then Exit Function
If LenB(Delimiter) = 0 Then Exit Function
' Allocate initial array
ReDim astrChunks(0 To ARRAY_INCREMENT - 1)
' Find the first delimiter
lngPosition = InStr(1, ToSplit, Delimiter)
lngLastPosition = 1
' Chop up the input string using the delimiter and put each chunk into the array
Do While lngPosition > 0
' Make sure there is enough space in the array for the next element
MakeSpace astrChunks, lngUsed, ARRAY_INCREMENT
' Add string to array
astrChunks(lngUsed) = Mid$(ToSplit, lngLastPosition, _
lngPosition - lngLastPosition)
' Reset string index for next interation
lngLastPosition = lngPosition + 1
' Find next delimiter (if any)
lngPosition = InStr(lngLastPosition, ToSplit, Delimiter)
' Increment counter for next iteration
lngUsed = lngUsed + 1
Loop
' Add last (or only chunk to the array)
MakeSpace astrChunks, lngUsed, ARRAY_INCREMENT
astrChunks(lngUsed) = Mid$(ToSplit, lngLastPosition)
' Trim array to correct size and return it to the user
ReDim Preserve astrChunks(0 To lngUsed)
Spliter = astrChunks
End Function
Private Function MakeSpace(ByRef astrArray() As String, _
ByVal lngUsed As Long, _
ByVal lngIncremnt As Long)
' Make sure there is enough space in the array for the next element
If lngUsed > UBound(astrArray) Then
' Increase array size
ReDim Preserve astrArray(0 To UBound(astrArray) + lngIncremnt - 1)
End If
End Function
You can in Office 2000, because it supports functions that return arrays. Try the above
and if it's no go well hack it into a Sub that returns an array (as the MakeSpace Sub
does).
HTH + Cheers - Peter
"Al Grant" <acgrant@orcon.net.nz>, said:
>After getting it working on my pc at home I found out we are on office 97 at
>work!!!
>
>No split command :-(
>
>-Al
>
>"Peter Hewett" <nospam@xtra.co.nz> wrote in message
>news:er13j0p9srss8t7a0v41772j1ngu4h50p9@4ax.com...
>> Hi Al Grant
>>
>> An earlier post in this thread uses Split so why not use that:
>>
>> Dim astrLines() as String
>>
>> astrLines() = Split(sAll, Chr$(13))
>>
>> then replace str1 with astrLines(0) , str2 with astrLines(1), etc.
>>
>> HTH + Cheers - Peter
>>
>>
>> "Al Grant" <acgrant@orcon.net.nz>, said:
>>
>> >Hmmm, I am getting closer with:
>> >
>> >Public Sub ParseClipboarData()
>> > Dim str1 As String
>> > Dim str2 As String
>> > Dim str3 As String
>> > Dim strId As String
>> > Dim strRNS As String
>> > Dim strName As String
>> > Dim strAddress As String
>> > Dim strWork() As String
>> >
>> >xstart = 1
>> >str1 = Mid(sAll, xstart, InStr(xstart, sAll, Chr(13)))
>> >MsgBox testval1
>> >xstart = InStr(xstart, sAll, Chr(13)) + 2
>> >str2 = Mid(sAll, xstart, InStr(xstart, sAll, Chr(13)) - xstart)
>> >MsgBox testval2
>> >
>> >but I still think their is a better way to increment xstart, rather than
>> >line by line?
>> >
>> >Cheers
>> >
>> >-Al
>> >
>> >"Jay Freedman" <jay.freedman@verizon.net> wrote in message
>> >news:hj12j09umv32hr4v6970gf4dq3eefsakhp@4ax.com...
>> >> Hi Al,
>> >>
>> >> In the VBA editor, go to the Tools > References dialog and check the
>> >> box next to Microsoft Forms 2.0 Object Library. That will make the
>> >> DataObject available. You'll have to repeat this in each template
>> >> project where you want to use a DataObject.
>> >>
>> >> --
>> >> Regards,
>> >> Jay Freedman
http://aspnet2.com/mvp.ashx?JayFreedman
>> >> Microsoft Word MVP FAQ:
http://word.mvps.org
>> >>
>> >> "Al Grant" <acgrant@orcon.net.nz> wrote:
>> >>
>> >> >Hmmm - I cant find dataobject as a type of variable, and I get a
>compile
>> >> >error - user-defined type not defined???
>> >> >
>> >> >-Al
>> >> >
>> >> >
>> >> >"Peter Hewett" <nospam@xtra.co.nz> wrote in message
>> >> >news:65lvi0lcdvcuj4lrmiu6nolqb58tv8tsb8@4ax.com...
>> >> >> Hi Helmut Weber
>> >> >>
>> >> >> No I didn't - you'd already posted the code in the previous thread!
>> >And
>> >> >Al's definitely
>> >> >> smart enough to do the integration.
>> >> >>
>> >> >> Cheers - Peter
>> >> >>
>> >> >>
>> >> >> Helmut Weber <elmkqznfwvccbf@mailinator.com>, said:
>> >> >>
>> >> >> >Hi Al,
>> >> >> >this is the part, which Peter took for granted:
>> >> >> >---
>> >> >> >Dim oDat As DataObject
>> >> >> >Dim sAll As String
>> >> >> >Set oDat = New DataObject
>> >> >> >oDat.GetFromClipboard
>> >> >> >On Error GoTo TheEnd
>> >> >> >sAll = oDat.GetText
>> >> >> >MsgBox sAll
>> >> >> >Exit Sub
>> >> >> >TheEnd:
>> >> >> >MsgBox "No text in Clipboard"
>> >> >> >---
>> >> >> >Greetings from Bavaria, Germany
>> >> >> >Helmut Weber
>> >> >> >"red.sys" & chr(64) & "t-online.de"
>> >> >> >Word XP, Win 98
>> >> >>
>> >> >> HTH + Cheers - Peter
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
>> >> >
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
>> >> >-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
>> >>
>> >
>> >
>> >
>> >
>> >-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
>> >
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
>> >-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
>>
>
>
>
>
>-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
>
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
>-----== Over 100,000 Newsgroups - 19 Different Servers! =-----