PDA

View Full Version : Solved: macro to save file in my documents



Pete
10-16-2008, 10:48 AM
Hi Experts

How would you construct a macro to save a file with exention .pdf in my documents folder.

Here is the tricky bit:

Rather than manually typing in the first part of the file name the macro uses a set table with names and page numbers to determine what to name the file before saving it.

so Table;-

USA page 1
UK page 2
India page 3

manual page breaks have been already inserted into the worksheet

Kenneth Hobs
10-16-2008, 11:28 AM
Not sure why you would save an xls as a pdf name. Without know more details, here is my guess.

Sub t()
Dim s as String
s = MyDocuments & "\" & Range("A1").Value & ".pdf"
MsgBox s
End Sub

Function MyDocuments() As String
Dim wshShell As Object
Set wshShell = CreateObject("WScript.Shell")
MyDocuments = wshShell.Specialfolders("MyDocuments")
Set wshShell = Nothing
End Function