在另存为中使用变量

问题描述 投票:0回答:0

多年来我一直在使用旧的 Excel 4 宏系统创建宏。不幸的是,在我升级到 365 后,其中一些无法使用。 我有 2 个关于保存发票的问题 第 1 期,我使用发票编号作为文件名将主副本保存到主发票文件夹中。我想使用变量“invoiceNumber”,但只设法使用 Activecell,但至少可以。

   Windows("acme - Invoice GB.xltx").Activate
Application.Goto Reference:="Invoice_N"
ChDir "f:\Finance\Invoices"
ActiveWorkbook.SaveAs Filename:="F:\Finance\Invoices\" & ActiveCell, FileFormat _
    :=xlOpenXMLWorkbook, CreateBackup:=False

第2期 我正在尝试将发票作为 PDF 保存到客户发票文件夹中,从发票中获取客户姓名

 ActiveWorkbook.Names.Add Name:="companyname", RefersToR1C1:="=Invoice!R9C1"


ChDir "F:\Clients and Prospects\" & companyname & "\Invoices"

    
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="I" & ActiveCell, Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True

它确实保存了,但在根文件夹中,它没有选择公司名称。 非常感谢任何帮助

它确实保存了,但在根文件夹中,它没有选择公司名称。 非常感谢任何帮助

excel vba
© www.soinside.com 2019 - 2024. All rights reserved.