私は vba にアクセスするのが初めてです....下記のガイドをお願いします: アクセス vba ツールを作成したいのですが、その目的は、複数の Excel ファイルのみを参照し、選択したすべての Excel ファイルを更新/編集するために新しい行を追加することです ( sheet1 の最初の行のように)、テキストは「ABC」です。そして、すべてのExcelファイルを保存して閉じます。ありがとうございました
1044 次
1 に答える
0
答えが見つかりました。以下は、さらに参照するためのコードです。
Dim Xl As Excel.Application
Dim XlBook As Excel.Workbook
Dim XlSheet As Excel.Worksheet
Dim MySheetPath As String
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
Dim varFile As Variant
With fDialog
.AllowMultiSelect = True
.Title = "Select File Location to Export XLSx :"
.InitialFileName = ""
If .Show = True Then
For Each varFile In .SelectedItems
GetFileName = varFile
MySheetPath = GetFileName
Set Xl = CreateObject("Excel.Application")
Set XlBook = GetObject(MySheetPath)
Xl.Visible = True
XlBook.Windows(1).Visible = True
Set XlSheet = XlBook.Worksheets(1)
Dim varInquiryID As Long
Dim varCentreFooter As String
Dim sHeader As String
varCentreFooter = " ABC "
XlSheet.PageSetup.CenterFooter = varCentreFooter
ActiveWorkbook.Save
ActiveWorkbook.Close
Next
End If
End With
Set Xl = Nothing
Set XlBook = Nothing
Set XlSheet = Nothing
于 2012-11-25T18:12:15.520 に答える