Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
Programming
 EXP Systems Forum : PDF reDirect : Programming
Topic: Merging PDF with VBS script Post Reply Post New Topic
Author Message
smisich
Newbie
Newbie
Avatar

Joined: 20 Apr 11
Location: New Zealand
Posts: 3
Quote smisich Replybullet Topic: Merging PDF with VBS script
    Posted: 20 Apr 11 at 12:34AM
Hi,
 
I need to be able to merge PDF's using VBS script.
 
Can someone send me the code for it?
 
I tried this but it comes up with a "expected end of statement error oin the first line"
 
    Dim oPDF As New PDF_reDirect_v25002.Batch_RC_AXD
    Dim Files_to_Merge(1) As String
    Dim TempBool As Boolean
   
    ' Files to Merge
Files_to_Merge(0) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD01_Income Budget Executive Summary.PDF"
Files_to_Merge(1) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD02_Broking Branch Executive Income Budget Summary.PDF"
    With oPDF
       
        TempBool = .Utility_Merge_PDF_Files("Y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\Merged_Files.pdf", Files_to_Merge)
       
        If Not TempBool Then
            ' NOTES ON ERROR CODES for oPDF.ErrorLastDLL
            ' 401 - One of the Input File could not be opened
            ' 410 - One of the Input File could not be decrypted
            MsgBox "An Error Occured: " & .LastErrorDescription & vbCrLf & _
                     "Error Number =" & Str$(.LastErrorNumber) & vbCrLf & _
                     "DLL Error Number =" & Str$(.ErrorLastDLL), _
                    vbExclamation
        Else
            MsgBox "Merge Successful.", vbInformation
        End If
       
    End With
   
    Set oPDF = Nothing
 
thanks
IP IP Logged
Michel_K17
Moderator Group
Moderator Group
Avatar
Forum Administrator

Joined: 25 Jan 03
Posts: 1584
Quote Michel_K17 Replybullet Posted: 20 Apr 11 at 10:53PM
HI there,

   My recommendation would be to check that the VBA code runs in Excel or Word before trying it out in VBS. For example, make sure that the component is properly registered. The error on the first line seems to imply that the ActiveX is not registered.

   Another possibility is to find out if VBS supports early binding. Perhaps you could try a late binding alternative (ie Dim oPDF as Object, and then use the CreateObject function).

   I am not very familiar with VBS (apart from the similarity to VBA), but those are the only two things that comes to my mind concerning what you are describing.

   Best regards,



Michel Korwin-Szymanowski
EXP Systems LLC
IP IP Logged
smisich
Newbie
Newbie
Avatar

Joined: 20 Apr 11
Location: New Zealand
Posts: 3
Quote smisich Replybullet Posted: 21 Apr 11 at 4:04AM
it works with excel. however I need it in a vbs script so that I can schedule it to run in a sql server scheduled job.
 
WHEN RUNNING THIS it says that there is
Microsoft VBScript runtime error (25, 8) : Type mismatch: 'Utility_Merge_PDF_Files'
any idea why?
 

Dim Files_to_Merge(12) 
Dim TempBool
Dim oPDF
TempBool =FALSE
set oPDF = CREATEOBJECT("PDF_reDirect_v25002.Batch_RC_AXD")
    
  ' Files to Merge
Files_to_Merge(0) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD01_Income Budget Executive Summary.PDF"
Files_to_Merge(1) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD02_Broking Branch Executive Income Budget Summary.PDF"
Files_to_Merge(2) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD03_Non Broking Branch Executive Income Budget Summary.PDF"
Files_to_Merge(3) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD04_Income Type Executive Income Budget Summary.PDF"
Files_to_Merge(4) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD05_Retained Income Comparison Executive Income Budget Comparison.PDF"
Files_to_Merge(5) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD06_Retained Income Cumulative Year on Year Comparison.PDF"
Files_to_Merge(6) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD07_Segment Split for Broking Branches Executive Income Budget Summary.PDF"
Files_to_Merge(7) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD08_New New Business Executive Income Budget Summary.PDF"
Files_to_Merge(8) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD09_Base Service Margin Executive Income Budget Summary.PDF"
Files_to_Merge(9) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD10_Document Charge Service Margin Executive Income Budget Summary.PDF"
Files_to_Merge(10) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD11_Referral Partner Executive Summary.PDF"
Files_to_Merge(11) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD12_Group Override Executive Income Budget Summary.PDF"
Files_to_Merge(12) = "y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\201102\IBD13_Broking Branches Premium Budget.PDF"

With oPDF
       Set   TempBool = .Utility_Merge_PDF_Files("Y:\Reporting\Budget Reports\2012\Report PDFs\Executive Summary2011\Merged_Files.pdf", Files_to_Merge)
        
       IfNot TempBoolThen
            ' NOTES ON ERROR CODES for oPDF.ErrorLastDLL
            ' 401 - One of the Input File could not be opened
            ' 410 - One of the Input File could not be decrypted
          MsgBox"An Error Occured: " & .LastErrorDescription & vbCrLf & _
                     "Error Number =" & CStr(.LastErrorNumber) & vbCrLf & _
                     "DLL Error Number =" & CStr(.ErrorLastDLL), _
                    vbExclamation
        Else
           MsgBox"Merge Successful.", vbInformation
        EndIf
        
    EndWith
    
    Set oPDF = Nothing



IP IP Logged
smisich
Newbie
Newbie
Avatar

Joined: 20 Apr 11
Location: New Zealand
Posts: 3
Quote smisich Replybullet Posted: 21 Apr 11 at 4:05AM

im getting a
Microsoft VBScript runtime error (25, 8) : Type mismatch: 'Utility_Merge_PDF_Files'

in idea why?
IP IP Logged
Michel_K17
Moderator Group
Moderator Group
Avatar
Forum Administrator

Joined: 25 Jan 03
Posts: 1584
Quote Michel_K17 Replybullet Posted: 22 Apr 11 at 1:13AM
Try defining your array as a string array like this:

Dim Files_to_Merge(12) as String

Also, it's possible that VBS does not accept datatypes in declarations (I am not sure). If that is the case, you may want to try to coerce your array to a string type.

Unfortunately, I do not know how to do coersion in VBS.

Anyway, the method
Utility_Merge_PDF_Files is expecting a string array.

I hope that helps,


Michel Korwin-Szymanowski
EXP Systems LLC
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum