Click here to Skip to main content
16,004,969 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: urgent help on book system Pin
Christian Graus1-Jun-05 11:15
protectorChristian Graus1-Jun-05 11:15 
Generalhelp on conversion Pin
Member 199825031-May-05 2:26
Member 199825031-May-05 2:26 
GeneralRe: help on conversion Pin
Dave Kreskowiak31-May-05 6:04
mveDave Kreskowiak31-May-05 6:04 
GeneralRe: help on conversion Pin
Robert Rohde31-May-05 8:14
Robert Rohde31-May-05 8:14 
GeneralRe: help on conversion Pin
Dave Kreskowiak31-May-05 15:52
mveDave Kreskowiak31-May-05 15:52 
GeneralRe: help on conversion Pin
Robert Rohde31-May-05 20:22
Robert Rohde31-May-05 20:22 
GeneralRe: help on conversion Pin
Dave Kreskowiak1-Jun-05 0:27
mveDave Kreskowiak1-Jun-05 0:27 
GeneralRe: help on conversion Pin
Member 19982501-Jun-05 1:47
Member 19982501-Jun-05 1:47 
pls this is my code for conversion of my excel to pdf but it isnt working.dont know where i am going wrong

Sub run()

'
' Makes some preliminary checks of the arguments.
' Quits the application is any problem is found.
End Sub


' ***********************************************
' XLS2PDF
'
' Converts a Excel xlsument to PDF using Adobe
' Distiller.
'
' Input: C:\Documents and Settings\Administrator\Desktop\*.xls
' sXlsFile - Full path to Excel xlsument.
' sPDFFile - Optional full path to output file.
' If not specified the output PDF file
' will be the same as the sXlsFile except
' file extension will be .pdf.
Function XLS2PDF(sXlsFile, sPDFFile)
Dim fso ' As FileSystemObject
Dim wdo ' As Excel.Application
Dim wxls ' As Excel.xlsument
Dim wxlss ' As Excel.xlsuments
Dim sPrevPrinter ' As String
Dim oDistiller ' As PDFDistiller.PDFDistiller.1
Set oDistiller = CreateObject("PDFDistiller.PDFDistiller.1")
If oDistiller Is Nothing Then
WScript.Echo "Error: Cannot create PDF xlsument. Adobe Acrobat " +
"Distiller is not available! Quiting..."
WScript.Quit 1
End If

Set fso = CreateObject("Scripting.FileSystemObject")
Set wdo = CreateObject("Excel.Application")
Set wxlss = wdo.xlsuments

sTempFile = fso.GetSpecialFolder(TemporaryFolder) + "\" + fso.GetTempName()

sXlsFile = fso.GetAbsolutePathName(sXlsFile)

' Debug outputs...
If bShowDebug Then
WScript.Echo "Xls file = '" + sXlsFile + "'"
WScript.Echo "Temporary file = '" + sTempFile + "'"
WScript.Echo "PDF file = '" + sPDFFile + "'"
End If

sFolder = fso.GetParentFolderName(sXlsFile)

If Len(sPDFFile) = 0 Then
sPDFFile = fso.GetBaseName(sXlsFile) + ".pdf"
End If

If Len(fso.GetParentFolderName(sPDFFile)) = 0 Then
sPDFFile = sFolder + "\" + sPDFFile
End If

' Remember current active printer
sPrevPrinter = wdo.ActivePrinter

'wdo.ActivePrinter = "Acrobat PDFWriter"
wdo.ActivePrinter = "Acrobat Distiller"

' Open the Excel xlsument
Set wxls = wxlss.Open(sXlsFile)

' Print the Excel xlsument to the Acrobat Distiller -
' will generate a postscript (.ps) (temporary) file
wdo.ActiveXlsument.PrintOut False, , , sTempFile

' This outcommented part was used while trying to use "Acrobat PDFWriter"
'Do While wdo.BackgroundPrintingStatus > 0
' 'Do nothing - just wait for printing to finish before closing Excel
'Loop

wxls.Close WdDoNotSaveChanges
wdo.ActivePrinter = sPrevPrinter
wdo.Quit WdDoNotSaveChanges
Set wdo = Nothing

' Debug output...
'If bShowDebug Then
WScript.Echo " Distilling to '" + sPDFFile + "'"
'End If

' Distill the postscript file to PDF
oDistiller.FileToPDF sTempFile, sPDFFile, "Print"
Set oDistiller = Nothing

' Delete the temporary postscript file...
fso.DeleteFile (sTempFile)

Set fso = Nothing
MsgBox ("done")
End Function

' *** MAIN **************************************

Call EchoLogo
Call EchoUsage
Call CheckArgs
Call XLS2PDF(arguments.Unnamed.Item(0), arguments.Named.Item("o"))

Set arguments = Nothing
MsgBox ("done")

End Function
MsgBox ("done")
End Sub



GeneralRe: help on conversion Pin
Dave Kreskowiak1-Jun-05 1:54
mveDave Kreskowiak1-Jun-05 1:54 
GeneralRe: help on conversion Pin
Member 19982501-Jun-05 2:24
Member 19982501-Jun-05 2:24 
GeneralRe: help on conversion Pin
Dave Kreskowiak1-Jun-05 7:32
mveDave Kreskowiak1-Jun-05 7:32 
GeneralRe: help on conversion Pin
Member 19982501-Jun-05 22:09
Member 19982501-Jun-05 22:09 
GeneralRe: help on conversion Pin
Dave Kreskowiak2-Jun-05 2:52
mveDave Kreskowiak2-Jun-05 2:52 
GeneralRe: help on conversion Pin
Member 19982502-Jun-05 21:07
Member 19982502-Jun-05 21:07 
GeneralRe: help on conversion Pin
Dave Kreskowiak3-Jun-05 5:19
mveDave Kreskowiak3-Jun-05 5:19 
GeneralVB.NET Databinding in Master/Detail Win Form Pin
kb4mindia31-May-05 2:17
kb4mindia31-May-05 2:17 
QuestionHow to let the Video keep my size? Pin
rushing31-May-05 1:55
rushing31-May-05 1:55 
AnswerRe: How to let the Video keep my size? Pin
Christian Graus31-May-05 12:01
protectorChristian Graus31-May-05 12:01 
GeneralRe: How to let the Video keep my size? Pin
rushing31-May-05 17:39
rushing31-May-05 17:39 
GeneralRe: How to let the Video keep my size? Pin
Christian Graus31-May-05 17:41
protectorChristian Graus31-May-05 17:41 
GeneralRe: How to let the Video keep my size? Pin
rushing31-May-05 20:02
rushing31-May-05 20:02 
GeneralRe: How to let the Video keep my size? Pin
Christian Graus31-May-05 21:43
protectorChristian Graus31-May-05 21:43 
QuestionHow to create a flat file report Pin
aaleon31-May-05 1:47
aaleon31-May-05 1:47 
AnswerRe: How to create a flat file report Pin
KaptinKrunch31-May-05 19:52
KaptinKrunch31-May-05 19:52 
GeneralTime Pin
ADY00730-May-05 23:32
ADY00730-May-05 23:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.