我有一個生成網頁的宏的工作表(代碼如下)。我想改變它,所以它會生成PDF。這可以做到嗎?如何在Excel的VB宏中發佈到PDF?
Sub publishwebpages()
'calculate how many iterations
x = 0
Sheets("webpagegen").Select
Range("n1").Select
Range("n1").Copy
noofpages = ActiveCell.Value
'step through and select each customer
For x = 0 To noofpages
'For x = 364 To 366
Sheets("listcust").Select
Range("A2").Select
ActiveCell.Offset(x, 0).Range("A1").Select
Selection.Copy
Sheets("webpagegen").Select
Range("l1").Select
ActiveSheet.Paste
'name folder and filename
Sheets("webpagegen").Select
Range("ac2").Select
Range("ac2").Copy
foldername = ActiveCell.Value
'publish pages
Range("d3:q80").Select
Application.CutCopyMode = False
Selection.Copy
ActiveWorkbook.PublishObjects.Add(xlSourceRange, "D:\Temp\" & foldername, "webpagegen", "$d$3:$q$80", xlHtmlStatic, "custweb08 current_8162", "").Publish (True)
Next x
End Sub
什麼版本的Excel? –
Office Excel 2010 – TruMan1