{"id":1158,"date":"2015-03-26T22:31:55","date_gmt":"2015-03-26T14:31:55","guid":{"rendered":"http:\/\/www.awaysoft.com\/taor\/?p=1158"},"modified":"2015-03-27T11:09:01","modified_gmt":"2015-03-27T03:09:01","slug":"%e4%bd%bf%e7%94%a8vba%e6%89%b9%e9%87%8f%e5%af%bc%e5%85%a5%e5%9b%be%e7%89%87%e5%88%b0%e8%a1%a8%e6%a0%bc%e4%b8%ad","status":"publish","type":"post","link":"https:\/\/actom.me\/blog\/%e4%bd%bf%e7%94%a8vba%e6%89%b9%e9%87%8f%e5%af%bc%e5%85%a5%e5%9b%be%e7%89%87%e5%88%b0%e8%a1%a8%e6%a0%bc%e4%b8%ad.html","title":{"rendered":"\u4f7f\u7528VBA\u6279\u91cf\u5bfc\u5165\u56fe\u7247\u5230\u8868\u683c\u4e2d"},"content":{"rendered":"<p>\u5728\u505a\u4e00\u4efd\u6750\u6599\u7684\u65f6\u5019\u9700\u8981\u5c06\u4e00\u4efd\u6e05\u5355\u4e0a\u7684\u4eba\u7684\u8eab\u4efd\u8bc1\u7167\u7247\u586b\u5165word\u6587\u6863\u4e2d\uff0c\u8003\u8651\u5230\u4eba\u6570\u8f83\u591a\uff0c\u5c31\u505a\u4e86\u4e0b\u9762\u8fd9\u4e2a\u5b8f\u6765\u5904\u7406\u3002<\/p>\n<p>\u56fe\u7247\u5b58\u653e\u5728pics\u76ee\u5f55\u4e0b\uff0c\u56fe\u7247\u540e\u7f00\u4e3a.jpg<\/p>\n<p>\u5bfc\u5165\u7684\u56fe\u7247\u540d\u79f0\u5b58\u653e\u5728list.txt\u4e2d\uff0c\u4e0d\u9700\u8981\u5e26.jpg<\/p>\n<pre class=\"lang:vb decode:true\">Function CreateTable() As Table\r\n    Dim docActive As Document\r\n    Dim celTable As Cell\r\n    Set docActive = ActiveDocument\r\n    Set CreateTable = docActive.Tables.Add( _\r\n        Range:=docActive.Range(Start:=0, End:=0), NumRows:=1, _\r\n        NumColumns:=3)\r\n    CreateTable.Borders.InsideLineStyle = wdLineStyleSingle\r\n    CreateTable.Borders.OutsideLineStyle = wdLineStyleSingle\r\n    \r\n    \r\n    CreateTable.Cell(1, 1).Range.Text = \"\u5e8f\u53f7\"\r\n    CreateTable.Cell(1, 2).Range.Text = \"\u59d3\u540d\"\r\n    CreateTable.Cell(1, 3).Range.Text = \"\u8bc1\u4ef6\"\r\n    \r\n    CreateTable.Columns(1).SetWidth ColumnWidth:=40, RulerStyle:=wdAdjustSameWidth\r\n    CreateTable.Columns(2).SetWidth ColumnWidth:=40, RulerStyle:=wdAdjustSameWidth\r\n    CreateTable.Columns(3).SetWidth ColumnWidth:=360, RulerStyle:=wdAdjustSameWidth\r\n    \r\nEnd Function\r\n\r\n\r\nFunction IsFileExists(ByVal strFileName As String) As Boolean\r\n    Dim objFileSystem As Object\r\n  \r\n    Set objFileSystem = CreateObject(\"Scripting.FileSystemObject\")\r\n    If objFileSystem.fileExists(strFileName) = True Then\r\n        IsFileExists = True\r\n    Else\r\n        IsFileExists = False\r\n    End If\r\nEnd Function\r\n\r\nSub InsertOne(tbl As Table, name As String)\r\n    Dim lastRow\r\n    Dim line\r\n    Dim pic\r\n    Dim picPath\r\n    Dim w\r\n    \r\n    tbl.Rows.Add\r\n    line = tbl.Rows.Count\r\n    picPath = \"pics\\\\\" &amp; name &amp; \".jpg\"\r\n    \r\n    tbl.Cell(line, 1).Range.Text = line - 1\r\n    tbl.Cell(line, 2).Range.Text = name\r\n    \r\n    If IsFileExists(picPath) = True Then\r\n        Set pic = tbl.Cell(line, 3).Range.InlineShapes.AddPicture(FileName:=picPath, SaveWithDocument:=True)\r\n        w = pic.Width\r\n        pic.Width = 340\r\n        pic.Height = 340 \/ w * pic.Height\r\n    End If\r\nEnd Sub\r\n\r\n\r\n\r\nSub ImportPicture()\r\n    Dim txt As String\r\n    Dim tbl As Table\r\n    \r\n    ChDir ActiveDocument.Path\r\n    Set tbl = CreateTable()\r\n        \r\n    Open \"list.txt\" For Input As #1\r\n    Do While Not EOF(1)\r\n        Line Input #1, txt\r\n        InsertOne tbl, txt\r\n    Loop\r\n    Close #1\r\nEnd Sub\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u505a\u4e00\u4efd\u6750\u6599\u7684\u65f6\u5019\u9700\u8981\u5c06\u4e00\u4efd\u6e05\u5355\u4e0a\u7684\u4eba\u7684\u8eab\u4efd\u8bc1\u7167\u7247\u586b\u5165word\u6587\u6863\u4e2d\uff0c\u8003\u8651\u5230\u4eba\u6570 &#8230; <a class=\"more-link\" href=\"https:\/\/actom.me\/blog\/%e4%bd%bf%e7%94%a8vba%e6%89%b9%e9%87%8f%e5%af%bc%e5%85%a5%e5%9b%be%e7%89%87%e5%88%b0%e8%a1%a8%e6%a0%bc%e4%b8%ad.html\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/posts\/1158"}],"collection":[{"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/comments?post=1158"}],"version-history":[{"count":3,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/posts\/1158\/revisions"}],"predecessor-version":[{"id":1162,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/posts\/1158\/revisions\/1162"}],"wp:attachment":[{"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/media?parent=1158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/categories?post=1158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/tags?post=1158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}