Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Convert to .PDF macro

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to convert excel to PDF EricBB Excel Discussion (Misc queries) 2 March 18th 09 04:03 PM
convert a formula into a macro Dave F Excel Discussion (Misc queries) 2 December 11th 06 10:34 PM
Macro to convert data Sujith[_2_] Excel Programming 4 September 19th 05 05:23 PM
Convert Macro into an Add-in file DAA[_2_] Excel Programming 1 April 17th 04 02:57 AM
Using Macro to convert 240 to PRN Kenneth Excel Programming 1 November 9th 03 11:43 PM


All times are GMT +1. The time now is 07:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"