Convert to .PDF macro
MyPath = "C:\test\"
then you do
MyPath & Application.PathSeparator
so remove the "\" from the end of mypath
also, I doubt there is a file that matches sourcestring. You don't create
one in this routine that I can see.
--
Regards,
Tom Ogilvy
"Ashish" wrote in message
oups.com...
Hi All,
I have a workbook in which there are mutiple sheets. I just want
the "Sheet1" to be converted into PDF from XLS and autoload the PDF
file to FTP. Can anyone help me on the VBA code for the same. The
code I am using to convert to PDF is:
Sub pdfPrint()
Dim MyPath As String
Dim SourceString As String, OutputString As String, Suffix As String
Dim fName As String
Dim strActivePrinter As String
' Get active printer.
strActivePrinter = Application.ActivePrinter
' Change to the Microsoft Fax printer driver.
'Application.ActivePrinter = "hp LaserJet 1015"
fName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4)
MyPath = "C:\test\"
Suffix = Format(Date, "ddmmmyy")
SourceString = MyPath & Application.PathSeparator & fName & ".pdf"
OutputString = MyPath & Application.PathSeparator & fName & Suffix &
".pdf"
Application.ActivePrinter = "Adobe PDF"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, printtofile:=True,
ActivePrinter:= _
"Adobe PDF", Collate:=True, prtofilename:="TestMacroas"
Application.ActivePrinter = strActivePrinter
FileCopy SourceString, OutputString
MsgBox OutputString
Kill SourceString
End Sub
In this code I am getting an error on "FileCopy SourceString,
OutputString".
Can anyone help me on this....
Thanks in advance,
Ashish
|