ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Toolsแนวทางการหา keyword มาปั่นโดยใช้ VBA (แชร์ code )
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: แนวทางการหา keyword มาปั่นโดยใช้ VBA (แชร์ code )  (อ่าน 1762 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
Ozone
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 290
ออฟไลน์ ออฟไลน์

กระทู้: 1,519



ดูรายละเอียด เว็บไซต์
« เมื่อ: 10 มีนาคม 2014, 22:37:49 »

พอดีกำลังปั่น แล้วคิดว่าทำไงจะหาบทความมาปั่นให้ไวได้อย่างไร ลงเอยกับ VBA Excel ข้างล่าง 

งดมาม่านะครับ สำหรับคนที่อ่าน code ได้ อาจจะมองออกว่ามันช่วยให้การหาบทความมาทำ layout ได้เร็วขึ้นอย่างไร แชร์ให้ดู และเมนต์กันสนุกๆ แบบได้ความรู้ด้วยนะครับ  wanwan017



Sub GetArticle01()
'
' GetArticle01 Macro
'


    Dim FilePath, Content As String
    Dim MyObj As Object, MySource As Object, file As Variant
   
    Dim needWord As Integer
    Dim xWord, xContent, yContent As String
   
    'Number of word required each lines
    needWord = 100
   
   
   
    FilePath = "D:\SPIN\asics running shoe\"
   
    MsgBox "Read all files from " & FilePath & "article*.* and then merge to current active cell ?", vbOKCancel
   
   
    row_number = 0
    file = Dir(FilePath)
    While (file <> "")
      If InStr(file, "article") > 0 Then
         Open FilePath & file For Input As #1
         Content = ""
         Start = False
         Do Until EOF(1)
            Line Input #1, LineFromFile
            'lineItems = Split(LineFromFile, vbCrLf)
            If Trim(LineFromFile) <> "" Then
                If Not Start Then
                    ActiveCell.Offset(row_number, 0).Value = LineFromFile
                    Start = True
                Else
                    Content = Content & " " & LineFromFile
                    'Split content when words > 200
               '     If Len(Trim(Content)) - Len(Replace(Content, " ", "")) + 1 > 200 Then
               '         ActiveCell.Offset(row_number, 1).Value = Content
               '         row_number = row_number + 1
               '         Content = ""
               '     End If
                End If
            End If
         Loop
         
         'Save the last content that have more than 100 words
         'If Len(Trim(Content)) - Len(Replace(Content, " ", "")) + 1 > 100 Then
         '   ActiveCell.Offset(row_number, 1).Value = Content
         '   row_number = row_number + 1
         'End If
         
         Close #1
         
         'Read content and write to excel

         
         
         xContent = ""
         xWord = Split(Content, ".")
         
         For i = 0 To UBound(xWord)
            If i < UBound(xWord) Then
                xContent = xContent & " " & xWord(i) & "."
            Else
                xContent = xContent & " " & xWord(i)
            End If
           
            If Len(Trim(xContent)) - Len(Replace(xContent, " ", "")) + 1 >= needWord Then
                ActiveCell.Offset(row_number, 1).Value = xContent
                row_number = row_number + 1
                yContent = xContent
                xContent = ""
            End If
         Next i
         
         'Write the last line
         If Len(Trim(xContent)) - Len(Replace(xContent, " ", "")) + 1 >= 50 Then
                ActiveCell.Offset(row_number, 1).Value = xContent
                row_number = row_number + 1
                xContent = ""
         Else
                'If word in last line < 50, append to previous line
                xContent = yContent & xContent
                ActiveCell.Offset(row_number - 1, 1).Value = xContent
                xContent = ""
         End If
         
       End If
       file = Dir
    Wend

   
   
End Sub
บันทึกการเข้า

CopperCrew
คนรักเสียว
*

พลังน้ำใจ: 32
ออฟไลน์ ออฟไลน์

กระทู้: 172



ดูรายละเอียด เว็บไซต์
« ตอบ #1 เมื่อ: 10 มีนาคม 2014, 23:19:47 »

ขอบคุณครับ .... น่าสนใจมากเลย  wanwan017
บันทึกการเข้า

http://www.club27001.com - Information Security Blog
greencheer
ก๊วนเสียว
*

พลังน้ำใจ: 28
ออฟไลน์ ออฟไลน์

กระทู้: 326



ดูรายละเอียด
« ตอบ #2 เมื่อ: 11 มีนาคม 2014, 02:07:19 »

งงเลยครับ

ใช้ยังไงหรอครับ
บันทึกการเข้า
Meaw-IE
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 346
ออฟไลน์ ออฟไลน์

กระทู้: 2,196



ดูรายละเอียด เว็บไซต์
« ตอบ #3 เมื่อ: 11 มีนาคม 2014, 06:36:44 »

ขอบคุณคับ  wanwan019
บันทึกการเข้า

click2charm
Verified Seller
เจ้าพ่อบอร์ดเสียว
*

พลังน้ำใจ: 611
ออฟไลน์ ออฟไลน์

กระทู้: 3,350



ดูรายละเอียด เว็บไซต์
« ตอบ #4 เมื่อ: 11 มีนาคม 2014, 06:39:07 »

เป็นบทความที่ดีและมีประโยชน์มากครับ

ปล.สอนหนู๋ใช้งานทีคร๊าบบ อิอิ
บันทึกการเข้า

buy high pr domain
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 69
ออฟไลน์ ออฟไลน์

กระทู้: 1,565



ดูรายละเอียด
« ตอบ #5 เมื่อ: 11 มีนาคม 2014, 07:10:48 »

งง  Tongue
บันทึกการเข้า

Order cheap cheap Price supermarket bazaar market shop sells shop online business Order cheap bazaar
หน้า: [1]   ขึ้นบน
พิมพ์