[Mabinogi]excel讀取指定角色包裹數(shù)據(jù)的VBA
snowmirai前段時(shí)間更新后可以將角色包裹數(shù)據(jù)保存到本地,但是每個(gè)角色的包裹數(shù)據(jù)都是單獨(dú)保存的,需要找東西要逐個(gè)打開比較笨重。所以花了一下午時(shí)間看了下VBA,寫了個(gè)可以讀取選定角色包裹(單選多選均可)的功能。保存模塊之后在工作表添加一個(gè)按鈕用于加載腳本就行了。
EXCEL VBA個(gè)人感覺是難懂還難用。。。

Sub Import_Item_TXT()
? ? ActiveSheet.Unprotect Password:="mabinogi"
? ??
? ? Dim objStream, StrData, Arr1, i As Long
? ??
? ? 'Dim rows_num
? ??
? ? Dim full_info As String
? ? Dim string_searchResult
? ??
? ? Dim item_name As String, item_other As String, item_id As String
? ? Dim item_id_key As String, item_otherinfo_key As String
? ??
? ? Dim pathX As String, item_Code As String, N As Long
? ??
? ? Dim String_reading As String
? ? String_reading = "已導(dǎo)入文本"
? ??
? ? Dim pathCollection As String
? ??
? ? With Application.FileDialog(msoFileDialogFilePicker)
? ? ? ? '////////////////打開文件/////////////
? ? ? ? With .Filters
? ? ? ? ? ? .Clear
? ? ? ? ? ? .Add "txt_File", "*.txt"
? ? ? ? End With
? ? ? ? .AllowMultiSelect = True
? ? ? ? .Show
? ? ? ? '/////////////////////////////////////
? ? ? ??
? ? ? ? '////////////////清除原有數(shù)據(jù)////////////
? ? ? ? ActiveSheet.UsedRange.ClearContents
? ? ? ? ActiveSheet.Cells.Interior.Pattern = xlNone
? ? ? ? '////////////////////////////////////////
? ? ? ??
? ? ? ? N = 3
? ? ? ? 'rows_num = 1
? ? ? ??
? ? ? ? For lngcount = 1 To .SelectedItems.Count
? ? ? ? ? ? j = 1
? ? ? ? ? ? Set objStream = CreateObject("ADODB.Stream")
? ? ? ? ? ? objStream.Charset = "utf-16"
? ? ? ? ? ? objStream.Open
? ? ? ? ? ? objStream.LoadFromFile (.SelectedItems(lngcount))
? ? ? ? ? ? StrData = objStream.readtext()
? ? ? ? ? ??
? ? ? ? ? ? Arr1 = Split(StrData, vbCrLf)
? ? ? ? ? ? objStream.Close
? ? ? ? ? ? Set objStream = Nothing
? ? ? ? ? ??
? ? ? ? ? ? ActiveSheet.Rows(N).Interior.Color = 65535
? ? ? ? ? ? Range("D" & N) = .SelectedItems(lngcount)
? ? ? ? ? ? For i = 0 To UBound(Arr1)
? ? ? ? ? ? ? ? string_searchResult = 0
? ? ? ? ? ? ? ? full_info = Arr1(i)
? ? ? ? ? ? ? ? '////////////////截取字符串////////////
? ? ? ? ? ? ? ? '? item_id_key? , item_otherinfo_key
? ? ? ? ? ? ? ? item_id_key = "ClassID"
? ? ? ? ? ? ? ? item_otherinfo_key = "Color"
? ? ? ? ? ? ? ? '//////////////////////////////////////
? ? ? ? ? ? ? ? '////////////////查找字符串///////////
? ? ? ? ? ? ? ? If (InStr(full_info, item_id_key)) Then
? ? ? ? ? ? ? ? ? ? string_searchResult = 1
? ? ? ? ? ? ? ? End If
? ? ? ? ? ? ? ? '///////////////////////////////////
? ? ? ? ? ? ? ? If full_info <> "" Then
? ? ? ? ? ? ? ? ? ? If (string_searchResult) Then
? ? ? ? ? ? ? ? ? ? ? ?item_name = Mid(full_info, 10, InStr(full_info, item_id_key) - 11)
? ? ? ? ? ? ? ? ? ? ? ?item_other = Mid(full_info, InStr(full_info, item_otherinfo_key) - 1)
? ? ? ? ? ? ? ? ? ? ? ?item_id = Mid(full_info, InStr(full_info, item_id_key) - 1, Len(Mid(full_info, InStr(full_info, item_id_key) - 1)) - Len(item_other))? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ?Range("B" & N) = item_name
? ? ? ? ? ? ? ? ? ? ? ?Range("C" & N) = item_id
? ? ? ? ? ? ? ? ? ? ? ?Range("D" & N) = item_other
? ? ? ? ? ? ? ? ? ? Else
? ? ? ? ? ? ? ? ? ? ? ?Range("A" & N) = full_info
? ? ? ? ? ? ? ? ? ?End If
? ? ? ? ? ? ? ? End If
? ? ? ? ? ? ? ? N = N + 1
? ? ? ? ? ? ? ? string_searchFault = 0
? ? ? ? ? ? Next
? ? ? ? Next lngcount
? ? ? ? 'MsgBox String_reading
? ? End With
? ? ActiveSheet.Protect Password:="mabinogi"
?End Sub