advanced help
per page, with , order by , clip by
Results of 1 - 1 of about 58 for CurrentDirectory (0.000 sec.)
[[20140917214830]]
#score: 13656
@digest: 7f02318e17dd86de19d6474fb5203bad
@id: 66141
@mdate: 2014-09-24T10:48:58Z
@size: 5164
@type: text/plain
#keywords: desktoppath (11730), currentdirectory (10304), textfiletrailingminusnumbers (6540), wscript (6389), textfilepromptonrefresh (6375), textfilesemicolondelimiter (6233), textfilespacedelimiter (6109), textfiletabdelimiter (5981), textfileconsecutivedelimiter (5981), パパ (5772), textfiletextqualifier (5755), xltextqualifierdoublequote (5700), textfileparsetype (5357), textfilestartrow (5341), textfilecolumndatatypes (5131), textfileplatform (5064), xlinsertdeletecells (4979), fieldnames (4833), savepassword (4833), トデ (4761), filladjacentformulas (4736), refreshperiod (4736), refreshonfileopen (4709), preserveformatting (4681), rownumbers (4613), textfilecommadelimiter (4557), savedata (4552), adjustcolumnwidth (4359), refreshstyle (4255), specialfolders (4234), ィレ (3973), backgroundquery (3549)
『テキストデータ読み込み』(パパス)
初めて!よろしくお願い致します。 デスクトップに作成されたテキストデータを Sheet1のA1に張り付ける為に以下のマクロを組んでいるのですが、、 ********** Sub test() Sheets("Sheet1").Select Range("A1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:¥Users¥papath¥Desktop¥txt.txt", Destination:=Range _ ("A1")) .Name = "ht_1" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = False .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 932 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = False .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = False .TextFileColumnDataTypes = Array(1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With End Sub ********** どの端末でも使える万能なマクロにするために、 テキストデータを都度選択するようなマクロを組みたいと思っています。 どのように修正すればよろしいでしょうか? ご教示よろしくお願い致します。 パパス < 使用 Excel:Excel2010、使用 OS:Windows8 > ---- ダイアログで選択させる方法です。 14 . ユーザーからの入力を受け付ける http://www.big.or.jp/‾seto/vbaref/vbaref14.htm でダイアログで選択したファイルを変数に格納して その変数をテキストファイルを貼り付ける部分のコード に渡してやります。 (カリーニン) 2014/09/17(水) 22:36 ---- ダイアログで開くフォルダを指定する場合は↓が参考になると思います。 ファイルを開くダイアログではじめに開くフォルダを設定する http://vbaexcel.seesaa.net/article/148313379.html なお、デスクトップは CreateObject("WScript.Shell").SpecialFolders("Desktop") とすれば現在のユーザーのデスクトップを指定できます。 (カリーニン) 2014/09/17(水) 23:43 ---- カリーニンさん すぐにご回答頂きありがとうございます! ファイルを開くダイヤログがあるんですね! でもどう記述していいか分からず難しそう… ということで、もうひとつ教えて頂いた、 CreateObject("WScript.Shell").SpecialFolders("Desktop") を使ってマクロボタン一つで作成したいと思うのですが、 うまく回りません… 今一度助けて頂けますでしょうか? ******** Sub test() Sheets("Sheet1").Select Range("A1").Select DesktopPath = CreateObject("WScript.Shell").SpecialFolders("Desktop") With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;DesktopPath¥txt.txt", Destination:=Range _ ("A1")) .Name = "ht_1" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = False .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 932 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = False .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = False .TextFileColumnDataTypes = Array(1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With End Sub ******** よろしくお願い致します。 (パパス) 2014/09/18(木) 10:35 ---- "TEXT;" & DesktopPath & "¥txt.txt" (???) 2014/09/18(木) 12:50 ---- ダイアログでファイルを選択するコードのサンプルです。 Dim WSH As Object Dim crdr As String Dim Ret As Variant Set WSH = CreateObject("WScript.Shell") 'カレントディレクトリ取得 crdr = CreateObject("WScript.Shell").CurrentDirectory 'カレントディレクトリ変更/今回はデスクトップに変更 CreateObject("WScript.Shell").CurrentDirectory = CreateObject("WScript.Shell").SpecialFolders("Desktop") '読み込むファイルをダイアログで指定 Ret = Application.GetOpenFilename("テキストファイル(*.txt),*.txt") 'キャンセルの場合 If Ret = False Then MsgBox "キャンセルが選択されました。" 'カレントディレクトリを戻す CreateObject("WScript.Shell").CurrentDirectory = crdr '終了 Exit Sub End If 'ダイアログで選択したファイルのパス MsgBox ret 'テキスト読み込みのコードをここに書く 'カレントディレクトリを戻す CreateObject("WScript.Shell").CurrentDirectory = crdr (カリーニン) 2014/09/18(木) 19:40 ---- ???さん そのように変更したら無事に回りました! 本当にありがとうございました! カリーニンさん 最後までご指導ありがとうございました!勉強になりました! (パパス) 2014/09/24(水) 19:48 ...
https://www.excel.studio-kazu.jp/wiki/kazuwiki/201409/20140917214830.txt - [detail] - similar
PREV NEXT
Powered by Hyper Estraier 1.4.13, with 97045 documents and 608223 words.

訪問者:カウンタValid HTML 4.01 Transitional