Click here to Skip to main content
15,891,204 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Dummie question: compiled language or not? Pin
Heywood3-Feb-09 14:44
Heywood3-Feb-09 14:44 
GeneralRe: Dummie question: compiled language or not? Pin
Jon_Boy4-Feb-09 2:42
Jon_Boy4-Feb-09 2:42 
AnswerRe: Dummie question: compiled language or not? Pin
Wendelius3-Feb-09 9:40
mentorWendelius3-Feb-09 9:40 
GeneralRe: Dummie question: compiled language or not? Pin
Sonhospa3-Feb-09 9:58
Sonhospa3-Feb-09 9:58 
GeneralRe: Dummie question: compiled language or not? Pin
Wendelius3-Feb-09 10:12
mentorWendelius3-Feb-09 10:12 
GeneralRe: Dummie question: compiled language or not? Pin
Dave Kreskowiak3-Feb-09 15:05
mveDave Kreskowiak3-Feb-09 15:05 
GeneralRe: Dummie question: compiled language or not? Pin
Luc Pattyn3-Feb-09 14:23
sitebuilderLuc Pattyn3-Feb-09 14:23 
QuestionPDFCreator Problems with Excel Pin
Dominick Marciano3-Feb-09 6:19
professionalDominick Marciano3-Feb-09 6:19 
Basically I have multiple Excel files and each file has four sheets. I am trying to print each work book to a separate PDF. The first work books converts to a PDF with no problem however on the second go-around PDFCreator hangs and only the last page of the second work book is saved as a PDF. I've been working on this nonstop for two days now and can't figure out what else to do. Below is the code (with comments) for the sub routine that is supposed to do the conversion. The lines between asterisks is where the code hangs. Thanks in advance. PS: Sorry for the long code.

With m_ExcelApp   'This is the Excel COM object
            .Visible = False  'Ensure that all work is done in the background

            pdfjob = New PDFCreator.clsPDFCreator   'The PDFCreator object is created

            '/// Make sure the PDF printer can start ///
            If pdfjob.cStart("/NoProcessingAtStartup") = False Then
                MsgBox("Can't initialize PDFCreator.", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error!")
                Exit Sub
            End If

            '/// This is opening up the Excel file one by one ///
            For i As Integer = 0 To IntDistList.Count - 1
                PSFileName = IntDistList(i).ToString.Insert(IntDistList(i).ToString.LastIndexOf("\"), "\Reports") & ".pdf"
                workbook = .Workbooks.Open(IntDistList(i).ToString.Insert(IntDistList(i).ToString.LastIndexOf("\"), "\Reports") & ".xml")
                sheet = .ActiveWorkbook.Sheets(2)
                sheet.Activate()
                sheet.PageSetup.PrintTitleRows = "$1:$9"
                sheet = .ActiveWorkbook.Sheets(3)
                sheet.Activate()
                sheet.PageSetup.PrintTitleRows = "$1:$10"
                .ActiveWorkbook.Save()

                '/// Change the output file name here ///
                div = PSFileName.Split("\")
                sPDFName = div(div.GetUpperBound(0))
                sPDFPath = PSFileName.Substring(0, PSFileName.LastIndexOf("\")) & "\"

                '/// Set all default settings ///
                With pdfjob
                    .cOption("UseAutoSave") = 1
                    .cOption("UseAutosaveDirectory") = 1
                    .cOption("AutosaveDirectory") = sPDFPath
                    .cOption("AutosaveFilename") = sPDFName
                    .cOption("AutosaveFormat") = 0    ' 0 = PDF
                    .cClearCache()
                End With

                '/// Print the file to PDF ///
                lTtlSheets = .Sheets.Count
                For lSheet = 1 To .Sheets.Count
                    If .Sheets(lSheet).usedrange IsNot Nothing Then
                        .Sheets(lSheet).printout(activeprinter:="PDFCreator")
                    Else
                        lTtlSheets -= 1
                    End If
                Next

                '/// Wait until all print job have entered the print queue ///
                '*******************This is where the program hangs on the second go-around but works fine for the first file*****************
                Do Until pdfjob.cCountOfPrintjobs = lTtlSheets
                    Thread.Sleep(30)
                Loop
                '************************************************

                '/// Combine all PDFs into a single file and stop the printer ///
                ChangeStatus("Combining Files")
                With pdfjob
                    .cCombineAll()
                    .cPrinterStop = False
                End With

                '/// Wait until PDF creator is finished then release the objects ///
                ChangeStatus("Finalizing File")
                Do Until pdfjob.cCountOfPrintjobs = 0
                    Thread.Sleep(1000)
                Loop

                Thread.Sleep(2500)

                ChangeStatus("Closing File")
                .ActiveWorkbook.Close()
                PSFileMerge.Add(PSFileName)

            Next

            ChangeStatus("Releasing Objects")
            pdfjob.cClose()
            pdfjob = Nothing

        End With

AnswerRe: PDFCreator Problems with Excel Pin
EliottA3-Feb-09 6:27
EliottA3-Feb-09 6:27 
GeneralRe: PDFCreator Problems with Excel Pin
Dominick Marciano3-Feb-09 6:39
professionalDominick Marciano3-Feb-09 6:39 
GeneralRe: PDFCreator Problems with Excel Pin
EliottA3-Feb-09 6:42
EliottA3-Feb-09 6:42 
GeneralRe: PDFCreator Problems with Excel Pin
Dominick Marciano3-Feb-09 7:14
professionalDominick Marciano3-Feb-09 7:14 
AnswerRe: PDFCreator Problems with Excel Pin
Dominick Marciano3-Feb-09 8:00
professionalDominick Marciano3-Feb-09 8:00 
QuestionWidth and Height of a Character Pin
Hari-Adarapu3-Feb-09 6:06
Hari-Adarapu3-Feb-09 6:06 
AnswerRe: Width and Height of a Character Pin
Dominick Marciano3-Feb-09 6:35
professionalDominick Marciano3-Feb-09 6:35 
GeneralRe: Width and Height of a Character Pin
Hari-Adarapu3-Feb-09 8:49
Hari-Adarapu3-Feb-09 8:49 
GeneralRe: Width and Height of a Character Pin
EliottA3-Feb-09 9:05
EliottA3-Feb-09 9:05 
GeneralRe: Width and Height of a Character Pin
Dominick Marciano3-Feb-09 9:19
professionalDominick Marciano3-Feb-09 9:19 
GeneralRe: Width and Height of a Character Pin
EliottA3-Feb-09 9:24
EliottA3-Feb-09 9:24 
GeneralRe: Width and Height of a Character Pin
0x3c03-Feb-09 9:31
0x3c03-Feb-09 9:31 
AnswerRe: Width and Height of a Character Pin
EliottA3-Feb-09 6:58
EliottA3-Feb-09 6:58 
GeneralRe: Width and Height of a Character Pin
Hari-Adarapu27-Feb-09 19:48
Hari-Adarapu27-Feb-09 19:48 
QuestionHow can I display international characters in a listview? Pin
JUNEYT3-Feb-09 5:40
JUNEYT3-Feb-09 5:40 
AnswerRe: How can I display international characters in a listview? Pin
Rupesh Kumar Swami3-Feb-09 9:26
Rupesh Kumar Swami3-Feb-09 9:26 
QuestionMS Access and VB.Net Pin
vijay24823-Feb-09 1:44
vijay24823-Feb-09 1:44 

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.