View Single Post
 
Old 07-10-2015, 08:06 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The main problem is that you're not specifying the file type when you save it; merely adding a PDF extension does not a PDF make. Your code could also be greatly simplified. Try:
Code:
Sub SaveDocument()
' this program saves the document in the Suntax Uploads folder on the user's desktop
Dim rng_claimant_id As Range, str_claimant_id As String
With ActiveDocument
  Set rng_claimant_id = .Range(Start:=ActiveDocument.Words(1).Start, End:=ActiveDocument.Words(1).End)
  str_claimant_id = Left(rng_claimant_id, Len(rng_claimant_id) - 1)
  .SaveAs2 FileName:="C:\Users\" & Environ("Username") & "\Desktop\Suntax Uploads\" & _
    str_claimant_id & ".pdf", Fileformat:=wdFormatPDF
End With
End Sub
PS: When posting code, please use the code tags, indicated by the # button on the posting menu.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote