[英]Excel vba code to save as pdf no longer works in excel 365 (windows 10)
ZC1D81AF583584B4E9D9369110DED8FDCZ Z6E3EC7E6A9A9F6007B4838FC0EE793A809Z代碼在Z0F4137ED1502B50B5045D6083A258B5C58B5 CNOCKEN Z7137B58B5 CONS 7(excelel oon Z0F4137ED137(Excelel)中,該代碼在
現在生成了運行時錯誤。
Run-time error '-2147024773 (8007007b)'
Document not saved
調試器突出顯示從第一個 ActiveSheet.ExportAsFixedFormat 開始的 4 行,一直到 False。
有沒有辦法改變我的代碼,以便在 windows 10 / excel 365 上運行?
Workbooks("Valuation Grail.xlsm").Save
Dim mydir As String
Dim mydrive As String
'Used activeworkbook.path instead of CurDir() because activeworkbook.path does not change for the same saved workbook
mydir = ActiveWorkbook.Path
mydrive = Left(mydir, 1)
'save original wmu as 2 PDFs
Dim month_end As String
Dim generic_vg As String
Dim archived_vg As String
Dim taa_packet As String
'creates saving format for archived pdf
month_end = Format(WorksheetFunction.EoMonth(Now(), -1), "yyyymmdd")
generic_vg = mydrive & ":\01\spec_folder\01 - DATA\Valuations Report\Valuations Report.pdf"
archived_vg = mydrive & ":\01\spec_folder\01 - DATA\Valuations Report\" & month_end & "-Valuations.pdf"
taa_packet = mydrive & ":\01\spec_folder2\#Packet Assembly\TAA\" & "12 - Valuation Grail.pdf"
'Saves the generic and archived version of valuation report to spce_folder data folder
ThisWorkbook.Sheets(Array("Table", "Table_SS")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
generic_vg, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
archived_vg, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
ThisWorkbook.Sheets("Summary").Select
'saves the pe tabs to the oshea packet assembly folder
ThisWorkbook.Sheets(Array("PE_Summary", "TAA_SS")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
taa_packet, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
ThisWorkbook.Sheets("Summary").Select
ActiveWorkbokk.Path
之前返回了工作簿所在的完整路徑,包括驅動器映射到的字母(Z、Y、X 等)。 然后,我將使用mydrive
僅提取該字母以在我的文件路徑中使用。 這種方法不再有效。
我更改了 mydrive = "Z" 並且代碼現在可以工作了。
理想情況下,我想找到一種新方法來提取該驅動器號,這樣我們團隊的成員就不必每次都手動更改 mydrive 變量,但這目前有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.