ปรุงก่อนชิม
Location :
นนทบุรี Thailand

[Profile ทั้งหมด]

ฝากข้อความหลังไมค์
Rss Feed
Smember
ผู้ติดตามบล็อก : 4 คน [?]




New Comments
Group Blog
 
All Blogs
 
Friends' blogs
[Add ปรุงก่อนชิม's blog to your web]
Links
 

 
การ ดูด textfile.CSV จาก Web server มาไว้ที่ ms excel

ตัวอย่าง code ที่ 1

Option Explicit

Sub transfercsv() 'ok is work
Dim URL As String
'URL = "TEXT;//www.investis.com/chartsource/csvdownload.csv?symbol=UBS.N&startday=14&startmonth=10&startyear=2007&endday=14&endmonth=10&endyear=2008&btnSubmitCvs.x=41&btnSubmitCvs.y=5"
URL = "TEXT;//10.112.250.43/increaseperformance/export/IncPerformance_20121001_162724.csv"

Application.DisplayAlerts = False
With ActiveSheet.QueryTables.Add(Connection:=URL, _
Destination:=Range("I4"))
.Name = "test"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
'.TextFilePlatform = 437
.TextFilePlatform = 874
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Application.DisplayAlerts = True
End Sub

ตัวอย่างที่ 2

Sub transfercsv() 'ok is work
Dim wnd As Window
Dim sCSVLink As String
Dim sfile As String
Dim ssheet As String
sCSVLink = "//10.112.250.43/increaseperformance/export/IncPerformance_20121001_162724.csv"
sfile = "IncPerformance_20121001_162724.csv"
ssheet = "CSV Transfer"

Set wnd = ActiveWindow
Application.ScreenUpdating = False
Sheets(ssheet).Cells.ClearContents
Workbooks Filename:=sCSVLink
Windows(sfile).Activate
ActiveSheet.Cells.Copy
wnd.Activate
Range("a1").Select
Sheets("CSV Transfer").Paste
Application.DisplayAlerts = False
Windows(sfile).Close False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub




Create Date : 08 พฤศจิกายน 2555
Last Update : 9 พฤศจิกายน 2555 10:56:54 น. 0 comments
Counter : 947 Pageviews.

ชื่อ :
Comment :
  *ใช้ code html ตกแต่งข้อความได้เฉพาะสมาชิก
 
 Pantip.com | PantipMarket.com | Pantown.com | © 2004 BlogGang.com allrights reserved.