UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Excel Selection To Pdf, Office 2010    
 
   
wornout
post Apr 9 2020, 03:41 PM
Post#1



Posts: 1,344
Joined: 17-November 13
From: Orewa New Zealand


I am trying to get my selected cells to save as a PDF but I want to pick the folder to save in and I want the PDF to be called Home Office and the date/time. I dont seem to beable to get the folder picker
[codelasttodorow = Worksheets("CustomerMgr").Range("W99999").End(xlUp).Row


Dim file_name As String

Worksheets("CustomerMgr").Range("W38:AF" & lasttodorow).Select



With Selection
.ExportAsFixedFormat Type:=xlTypePDF, FileName:= "Home Office" & " " & Format(Now(), "dd.mm.yy hh.mm") & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End With

End Sub
][/code]
at the moment it just opens the PDF with the right name.
Go to the top of the page
 
June7
post Apr 9 2020, 04:22 PM
Post#2



Posts: 1,390
Joined: 25-January 16
From: The Great Land


Thanks for trying CODE tags but messed up pasting.

Not seeing any code for file picker. Use FileSystemObject code for that.



--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Go to the top of the page
 
ADezii
post Apr 9 2020, 05:27 PM
Post#3



Posts: 2,988
Joined: 4-February 07
From: USA, Florida, Delray Beach


Here is a similar example, using Early Binding that will output the Selection in a Worksheet to a *.pdf File. You are already designating a Filename, so I opened the Folder Dialog instead.
CODE
'First, set a Reference to the Microsoft Office XX.X Object Library
Dim strFolder As String
Dim dlgOpen As Office.FileDialog
Dim lngLastRowWithData As Long

Set dlgOpen = Application.FileDialog(msoFileDialogFolderPicker)

lngLastRowWithData = Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row

With dlgOpen
  .AllowMultiSelect = False
  .ButtonName = "Select Folder"
  .Title = "Browse for Folders"
  .InitialView = msoFileDialogViewLargeIcons
  .InitialFileName = ActiveWorkbook.Path
    If .Show <> -1 Then Exit Sub
      strFolder = .SelectedItems(1)
End With

Worksheets("Sheet1").Range("A1:G" & CStr(lngLastRowWithData)).Select

With Selection
   .ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFolder & "\" & Format(Now(), "dd.mm.yy hh.mm") & ".pdf", _
                        Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
                        OpenAfterPublish:=True
End With

This post has been edited by ADezii: Apr 9 2020, 05:30 PM
Go to the top of the page
 
wornout
post Apr 9 2020, 06:57 PM
Post#4



Posts: 1,344
Joined: 17-November 13
From: Orewa New Zealand


Whoops I did sorry, more haste less speed
Go to the top of the page
 
wornout
post Apr 9 2020, 07:10 PM
Post#5



Posts: 1,344
Joined: 17-November 13
From: Orewa New Zealand


Thanks @A Dezii thay work a treat cheers.gif
Go to the top of the page
 
ADezii
post Apr 10 2020, 07:04 AM
Post#6



Posts: 2,988
Joined: 4-February 07
From: USA, Florida, Delray Beach


yw.gif
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    25th May 2020 - 03:02 AM