Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-10-2015, 08:06 PM
macropod's Avatar
macropod macropod is offline Program-generated .pdf file unable to be opened Windows 7 64bit Program-generated .pdf file unable to be opened 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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Project cannot save - file cannot be opened Guloluseus Project 22 01-28-2015 07:23 AM
Word Changes File Name When Opened canonm@pacbell.net Word 1 06-11-2014 10:04 PM
2007 file opened with 2010 messed up Intruder Project 1 11-21-2013 01:04 PM
Weird message “the file ( ) should be opened as read-only unless changes to it need t Jamal NUMAN Word 6 11-13-2013 01:53 AM
'Save As' to same folder as original opened file thepuppyprince Office 0 01-18-2013 08:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:13 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft