Results 1 to 3 of 3

Thread: vba, .printout set to 1 page only

  1. #1

    vba, .printout set to 1 page only

    Hello everyone,

    I have created a delivery note which take data from some Forms, copies them to a sheet then the data from that sheet is used to populate an email table and sent by .send though outlook. I have the below code. at the end I have a .printout function that works fine but it takes 2 pages because of the email signature which I feel is a waste of paper so I have been trying to force the code to print out just 1 page. The below is what I have but is still printing out 2 pages. help please

    Code:
    strbody = "<table cellpadding='2' align='left' style='color: #cc3333; width: 600px; min-width: 600px; text-align: center; background: #ffcc00; font-size: 16px'>" & _
                  "<tr><td><img src='http://www.stepstone.de/upload_de/logo/D/logoDHL_Global_Forwarding_40393DE.gif' /></td><td colspan='2' style='font-size: 36px; font-weight: bolder; text-align: center'>Delivery Instruction</td></tr>" & _
                  "<tr><td colspan='3' style='border-bottom: 2px solid #cc3333'></td></tr>" & _
                  "<tr><td colspan='3' style='text-align: left; text-indent: 30px'>Dear " & ToName.Value & ",</td></tr>" & _
                  "<tr><td colspan='3' style='text-align: center; vertical-align: top; font-weight: bold'>Please can you arrange the delivery to " & oTown.Value & ", " & " as per the following details.</td></tr>" & _
                  "<tr><td colspan='3' style='font-weight: bolder; font-size: 20px; color: #ffcc00; background: #cc3333'>Shipment Details</td></tr>" & _
                  "<tr><td colspan='3' style='height: 5px'></td></tr>" & _
                  "<tr><td>Our ref: " & oFile.Value & "</td><td>Vessel: " & oVessel.Value & "</td><td>ETA: " & oETA.Value & "</td></tr>" & _
                  "<tr><td>Container: " & oCont1.Value & "</td><td>Size: " & oSize1.Value & "</td><td>Bill of Lading: " & oBL.Value & "</td></tr>" & _
                  "<tr><td>Weight: " & oWeight1.Value & " Kgs" & "</td><td style='text-align: left'>Port of Discharge: " & oPOD.Value & "</td>" & _
                  "<td>Goods: " & oGoodsDesc1.Value & "</td></tr>" & _
                  "<tr><td colspan='3' style='height: 5px'></td></tr>" & _
                  "<tr><td colspan='3' style='font-weight: bolder; font-size: 20px; color: #ffcc00; background: #cc3333'>Delivery address</td></tr>" & _
                  "<tr><td colspan='3' style='height: 5px'></td></tr>" & _
                  "<tr><td colspan='3'>" & oDelName.Value & "<br />" & oLine1.Value & "<br />" & oLine2.Value & "<br />" & oTown.Value & "<br />" & oCounty.Value & "<br />" _
                  & oPC.Value & "</td></tr>" & _
                  "<tr><td colspan='3' style='height: 5px'></td></tr>" & _
                  "<tr><td colspan='3' style='font-weight: bolder; font-size: 20px; color: #ffcc00; background: #cc3333'>Booking details</td></tr>" & _
                  "<tr><td colspan='3' style='height: 5px'></td></tr>" & _
                  "<tr><td colspan='3'>Date: " & oDelDateTime1.Value & "</td></tr>" & _
                  "<tr><td colspan='3'>Booking Ref: " & oDelRef1.Value & "</td></tr>" & _
                  "<tr><td colspan='3'><b><u>Special Instructions:</u></b></td></tr>" & _
                  "<tr><td colspan='3'>" & oSpecIns1.Value & "</td></tr>" & _
                  "</table>"
         strSig = "<table align='left'>" & _
                  "<tr><td style='font-size: 0.4em'>" & Signature & "</td></tr>" & _
                  "</table>"
                  
         StrMainTable = "<table><tr><td>" & strbody & "</td></tr>" & _
                        "<tr><td>" & strSig & "</td></tr></table>"
    
        On Error Resume Next
        
        With OutMail
            .to = oSendto.Value
            .CC = ""
            .BCC = ""
            .Subject = "Delivery Booking to " & oTown.Value & ", " & "Container: " & oCont1.Value & ", " & "Vessel: " & oVessel.Value & _
            ", " & "Bill of Lading: " & oBL.Value & ", " & "Our Ref: " & oFile.Value
            .HTMLBody = StrMainTable
            .HTMLBodyFormat = olFormatHTML
            .Zoom = False
            .HTMLBody.FitToPagesWide = 1
            .HTMLBody.FitToPagesTall = 1
            .PrintOut
            .Send
        End With
        Set OutApp = Nothing
        Set OutMail = Nothing

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    Did you check if you can print just one page by passing some parameter?
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Thank you. I did try the following with no joy..
    Code:
    .Printout From:=1 To:=1

Similar Threads

  1. VBA Macro To Print With Custom From And To Page Numbers
    By muhammad susanto in forum Excel Help
    Replies: 1
    Last Post: 12-23-2013, 03:11 PM
  2. Replies: 2
    Last Post: 04-15-2013, 02:23 PM
  3. VBA Validation List set
    By xander1981 in forum Excel Help
    Replies: 3
    Last Post: 02-15-2013, 04:07 PM
  4. Feed / Post Data on Web Page Using VBA
    By in.vaibhav in forum Excel Help
    Replies: 10
    Last Post: 01-10-2013, 05:00 PM
  5. Set Chart size using VBA
    By LalitPandey87 in forum Excel Help
    Replies: 3
    Last Post: 11-08-2011, 08:54 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •