[請問] excel的巨集

作者: meowde (甜水胡同)   2018-07-31 12:07:39
想請問擅長excel的大大們
如果要開啟多個檔案,每次開啟都套用某模式開啟
巨集開啟檔案那部分要怎麼改會比較好呢@@?
目前錄製僅能開啟相同的檔案,
如果開啟其他舊檔案變成還要手動再去全部重案
跪求高手大大解答TT
只能手動一個一個把檔名複製貼上嗎?
還是可以用甚麼方法去套用在每個檔案上呢?
謝謝..
以下是巨集內容
Sub TEST3()
'
' TEST3 巨集
'
'
Workbooks.OpenText Filename:="W:\●個人工作區\XXXXXXXXXXXXXXXXXXXXXXX.TXT", _
Origin:=950, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _
, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _
Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1)), TrailingMinusNumbers:=True
Range("H4:I9").Select
With Selection.Font
.Name = "Arial Unicode MS"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.Name = "Arial Unicode MS"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub
作者: amethystboy (紫晶男)   2018-07-31 12:49:00
Application.GetOpenFilenameWorkbooks.Open
作者: meowde (甜水胡同)   2018-07-31 13:44:00
a大謝謝您>< 請問是加在最一剛開始的地方嗎?是不固定檔名,但是固定的路徑...
作者: xcoldx (反覆默念的情話)   2018-07-31 20:46:00
寫個迴圈資料夾逐個檔案開啟
作者: darkMood (瞬間投射)   2018-07-31 21:11:00
需求不清不楚啊
作者: yzfr6 (扮關二哥!)   2018-08-01 18:46:00
自己先釐清一下開檔、檔名的規則,再來談怎麼寫

Links booklink

Contact Us: admin [ a t ] ucptt.com