2017-01-19 2 views
0

ExcelテンプレートでWebクエリを作成し、それをVBAで更新したいとします。ExcelセルフフィードWebクエリURLを受け入れる

通常、Webクエリを作成するには、ExcelにURLを指定する必要があります。 私の場合、URLにはファイルの名前が入ります。FILEXXXX(XXXXは数値文字列です)。結果として得られるURLはFILE0001のようになりますhttp://urlbabble/babblebabble_query=FILE0001

ExcelでこのURLを生成して自己フィードする方法はありますか?

VBAはオプションです。

答えて

0

は私がURLに変数を埋め込むためのコードを編集し、マクロを記録し、管理することにより、

Sub web_query() 
' web_query Macro 
' This macro generates the web query used to populate sheet' 
'get the file ID 
FILE_ID = Sheets("intake").Range("B1") 
If FILE_ID <> "" Then 
    With Sheets("web_query").QueryTables.Add(Connection:="URL;http://url part1" 
    _& FILE_ID & "url part2", Destination:=Sheets("web_query").Range("$A$1")) 
     .Name = "query=short_descriptionLIKE" & FILE_ID & "&row_count=999999999" 
     .FieldNames = True 
     .RowNumbers = False 
     .FillAdjacentFormulas = False 
     .PreserveFormatting = True 
     .RefreshOnFileOpen = False 
     .BackgroundQuery = True 
     .RefreshStyle = xlInsertDeleteCells 
     .SavePassword = False 
     .SaveData = True 
     .AdjustColumnWidth = True 
     .RefreshPeriod = 0 
     .WebSelectionType = xlEntirePage 
     .WebFormatting = xlWebFormattingNone 
     .WebPreFormattedTextToColumns = True 
     .WebConsecutiveDelimitersAsOne = True 
     .WebSingleBlockTextImport = False 
     .WebDisableDateRecognition = False 
     .WebDisableRedirections = False 
     .Refresh BackgroundQuery:=False 
    End With 
End If 
End Sub 
関連する問題