Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).

New Forum | Previous | Next | (P-PDF) Developers

Topic: How to manage save as prompt after converting the file into pdf
Conf: (P-PDF) Developers, Msg: 126832
From: mithun
Date: 2/1/2005 07:03 PM

Hi all i am creating a vb application to convert different documents into pdf but what happens after converting the document into pdf it prompts a save as block to save the pdf file i dont want this i want to save the converted file into specified location without prompting a save as block through coding.

my code is:
'Option Explicit
Dim objfs As Object
Dim sfolder
Dim mFile

Function ConvertFile(strSourceFileName As String, ext As String) As String
On Error GoTo ErrorHandler

If ext = "doc" Then
Dim msWord As Word.Application
Set msWord = CreateObject("Word.Application.8")
msWord.Visible = True
'msWord.ActivePrinter = "PDF4U ADOBE PDF CREATOR"
msWord.ActivePrinter = "PDF995"
msWord.Documents.Open strSourceFileName

' HKEY_CURRENT_USER \Software\Adobe\Acrobat PDFWriter\bDocInfo=0
msWord.ActiveDocument.Close (False)
msWord.Application.Quit (True)

Set msWord = Nothing
ConvertFile = True
Exit Function

ElseIf ext = "xls" Then
Dim msExcel As Excel.Application
Dim msWorkbook As Excel.Workbook
Dim ws As Worksheets
Set msExcel = CreateObject("Excel.application")

msExcel.Visible = True
msExcel.Workbooks.Open strSourceFileName, UpdateLinks:=False
msExcel.ActiveWorkbook.PrintOut ActivePrinter:="PDF4U ADOBE PDF CREATOR"

msExcel.ActiveWorkbook.Close (False)
Set msWorkbook = Nothing
Set msExcel = Nothing
ConvertFile = True
Exit Function

ElseIf ext = "ppt" Then
Dim msppt As PowerPoint.Application
Set msppt = CreateObject("PowerPoint.Application")

msppt.Visible = True

msppt.Presentations.Open strSourceFileName
msppt.ActivePresentation.PrintOptions.ActivePrinter = "PDF4U ADOBE PDF CREATOR"


Set msppt = Nothing
ConvertFile = True
Exit Function
End If

MsgBox Err.Description
If Err.Number = 429 Then

MsgBox Err.Description
Set msWord = CreateObject("Word.Application.8")
End If

If IsCriticalError Then
ConvertFile = False

Exit Function
End If

End Function

Private Function IsCriticalError() As Boolean
Dim strErrorMessage As String
Select Case Err.Number
Case Else
strErrorMessage = "Please contact mithun and inform him that" & Chr$(13) & _
"the error message reported by the operating system was " & Chr$(13) & _
Chr$(34) + Trim(Str(Err.Number)) & " " & Err.Description + Chr$(34)
MsgBox strErrorMessage, , "Conversion error" + Str(Err.Number)
IsCriticalError = True
Exit Function
End Select
IsCriticalError = False
End Function

Private Sub btnConvert_Click()
Dim strFileToConvert As String
Dim strFolder As String
Dim fext As String
Dim subfolder

'strFolder = m_txtSource

Set objfs = CreateObject("Scripting.FileSystemObject")
Set sfolder = objfs.GetFolder("D:\test")

For Each subfolder In sfolder.SubFolders
fname = subfolder.Name
Set fo1 = objfs.GetFolder("D:\test\" & fname)
For Each mFile In fo1.Files

fext = Mid(mFile.Name, InStr(1, mFile.Name, ".") + 1)

strFileToConvert = "D:\test\" & fname & "\" & mFile.Name

If strFileToConvert <> "" Then

If (ConvertFile(strFileToConvert, fext) = False) Then
If (MsgBox("There has been a problem converting the file " + strFileToConvert + "Do you wish to exit", vbYesNo) = vbYes) Then
Exit Sub
End If
End If
End If
Unload Me

End Sub

PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Five visions of a PDF Day

In the world of PDFs or as we like to say Planet (of) PDF, a year isn't a real PDF year without an intense few days of industry knowledge sharing.

May 15, 2018
Platinum Sponsor

Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.


Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.