我是VBA的新品牌。但我在SAS中编程了一点,在Assembler(大型机和PC),Word Perfect(宏),Java,HTML,其他东西中都有一点编程。我所做的是,当我遇到问题并且我认为我可以编程时,我会在互联网上查找代码并根据我的需要进行调整。我已经阅读了一些VBA编程。我想要做的是创建一个宏来保存一堆带有PDFMAKER的Outlook电子邮件。到目前为止,我已经提出了以下内容。当我执行该程序时,pmkr2被分配类型" ObjectPDFMaker"和stng分配类型" ISettings"。到现在为止还挺好。然后我尝试设置stng而不能这样做。我收到错误"找不到方法或数据成员。"如果我摆脱设置它突出显示.ISettings和我得到相同的错误。我进入F2并且AdobePDFMakerforOffice库就在那里,类ISettings就在那里,但我似乎无法设置stng。我很沮丧。请帮忙。
Sub ConvertToPDFWithLinks()
Dim pmkr2 As Object
Set pmkr2 = Application.COMAddIns.Item(6).Object ' Assign object reference.
Dim pdfname As String
pdfname = "C:\stuff\stuff\tester.pdf"
Dim stng As AdobePDFMakerForOffice.ISettings
Set stng = AdobePDFMakerForOffice.ISettings
stng.AddBookmarks = True
stng.AddLinks = True
stng.AddTags = True
stng.ConvertAllPages = True
stng.CreateFootnoteLinks = True
stng.CreateXrefLinks = True
stng.OutputPDFFileName = pdfname
stng.PromptForPDFFilename = False
stng.ShouldShowProgressDialog = True
stng.ViewPDFFile = False
pmkr.GetCurrentConversionSettings stng
pmkr2.CreatePDFEx stng, 0
Set pmkr2 = Nothing ' Discontinue association.
End Sub
答案 0 :(得分:0)
我稍微更新了你的代码。看看这是否有任何影响:
Sub ConvertToPDFWithLinks()
Dim pmkr2 As AdobePDFMakerForOffice.PDFMaker
'Set pmkr2 = Application.COMAddIns.Item(6).Object ' Assign object reference.
Set pmkr2 = Nothing
For Each a In Application.COMAddIns
If InStr(UCase(a.Description), "PDFMAKER") > 0 Then
Set pmkr2 = a.Object
Exit For
End If
Next
If pmkr2 Is Nothing Then
MsgBox "Cannot Find PDFMaker add-in", vbOKOnly, ""
Exit Sub
End If
Dim pdfname As String
pdfname = "C:\stuff\stuff\tester.pdf"
Dim stng As AdobePDFMakerForOffice.ISettings
pmkr2.GetCurrentConversionSettings stng
stng.AddBookmarks = True
stng.AddLinks = True
stng.AddTags = True
stng.ConvertAllPages = True
stng.CreateFootnoteLinks = True
stng.CreateXrefLinks = True
stng.OutputPDFFileName = pdfname
stng.PromptForPDFFilename = False
stng.ShouldShowProgressDialog = True
stng.ViewPDFFile = False
pmkr2.CreatePDFEx stng, 0
Set pmkr2 = Nothing ' Discontinue association.
End Sub
主要的变化是如何获得插件以及如何创建stng。