简体   繁体   中英

give name to workbook vba

My question may be very simple for some. I want to add a workbook using VBA code and name is "AAA" or "AAA.xlsx". Can some one please help.

I tried:

Set outputWorkbook = Workbooks.Add

With outputWorkbook

    .Name = "AAA"
End With

or

Set outputWorkbook = Workbooks.Add

outputWorkbook.Name = "AAA"

They don't seem to be working. I get error as

"Compile Error: Cant assign to read-only property"

I figured this out as a possible solution

Set outputWorkbook = Workbooks.Add

outputWorkbook.Windows(1).Caption = "AAA"

Does this look right?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM