The code below runs great in Excel 2010, but hangs with a "Object doesn't support this property or method" error on the line with the ExportAsFixedFormat statement near the bottom. Is this a syntax issue or does ExportAsFixedFormat really not exist in Office 2003 objects?
I searched for this for a while, but then remembered that the people here generally explain things much better than the MS reference sites.
Sorry for the long sub but posting the whole thing seems to be best.
Thanks.
![]()
Sub cCreateContractAwardDocuments() 'Creates a PDF from the contract award document template Dim wd As Word.Application Dim wdocSource As Word.Document Dim i As Long, j As Long Dim ContractRecord As Long Dim PDFPath As String Dim PDFFileName As String On Error Resume Next Set wd = GetObject(, "Word.Application") If wd Is Nothing Then Set wd = CreateObject("Word.Application") End If On Error GoTo 0 ContractRecord = ActiveCell.Row MasterWordFile = Workbooks(TableFileName).Sheets("Administrative").Range("$B$8").Value & _ Workbooks(TableFileName).Sheets("Administrative").Range("$B$11").Value & "\" & _ Workbooks(TableFileName).Sheets("Administrative").Range("$B$13").Value PDFPath = Workbooks(TableFileName).Sheets("Administrative").Range("$B$8").Value & _ Workbooks(TableFileName).Sheets("Administrative").Range("$B$9").Value & "\" & _ AwardFolderID(ContractRecord) & "\" & _ "3 Award\" PDFFileName = PDFPath & Workbooks(TableFileName).Sheets("Administrative").Range("$B$12").Value If Not FolderExists(PDFPath) Then MsgBox "An award folder for the row you have selected does not exist. You must first select a cell on the applicable ROW and run the CreateNewAwardFolder." Exit Sub Else End If If FolderExists(PDFFileName) Then Response = MsgBox("A PDF named:" & vbCrLf & vbCrLf & PDFFileName & vbCrLf & vbCrLf & "already exists. Overwrite?", vbYesNo) If Response = vbNo Then Exit Sub Else End If Else End If Set wdocSource = wd.Documents.Add(MasterWordFile) With ActiveSheet.Range("A1") For i = 1 To .CurrentRegion.Columns.Count wdocSource.Variables.Item(.Offset(0, i - 1)).Value = ScrubData(.Offset(ActiveCell.Row - 1, i - 1)) Next i If wdocSource.Variables.Item("AE Firm Contract Number").Value = " " Then wdocSource.Variables.Item("AE Firm").Value = "AE Firm Not Applicable" End If End With With wdocSource .Range.Fields.Update .ExportAsFixedFormat PDFFileName, 17 .Close SaveChanges:=False End With wd.Quit Set wdocSource = Nothing Set wd = Nothing If FolderExists(PDFFileName) = True Then MsgBox "Contract award documents successfully created and stored in:" & vbCrLf & vbCrLf & PDFFileName Else MsgBox "There was a problem." & vbCrLf & vbCrLf & "The contract documents were not created." Exit Sub End If End Sub
Bookmarks