Closed Thread
Results 1 to 2 of 2

2 problems with creating a print button on a userform

Hybrid View

  1. #1
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2010
    Posts
    28

    2 problems with creating a print button on a userform

    Dear All,

    I created a button on a userform to print an offer document.
    I us the userform to insert the offer proposition number and to select the language to print out the document.
    Once i push the print button on the userform, i would like:
    - the offer document printed as PDF in the selected language(s) and saved in a folder
    - the complete excel document saved as xlsm in the same folder

    I wrote a formula in vba, based on what i found on internet, because it's the first time that i use VBA or anything like it.
    The button does already 90% of what it should ;-)

    But i have problems with the 2 last item that i want to add to the formula.
    1.Save the complete excel document as xlsm in the same folder.
    2.When i use the print button and the proposition already exists, the old document gets overwritten. Isn't it possible to check the folder for existing file names and pop up a message box when the file name already exists. So that the action is not carried out, but that you are required to enter another number.

    Can someone help me, please?

    This is the formula that i wrote:

    P
    rivate Sub CommandButton1_Click()
    
    pname = ThisWorkbook.Path
    Number = TextBox1.Text
    Installer = Blad1.Range("B2").Text
    Client = Blad1.Range("G2").Text
    typ = Blad1.Range("A16").Text
    
    If TextBox1.Text = "" Then
    MsgBox "No proposition number given!", vbOKOnly, "Error Proposition"
    ElseIf CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False Then
    MsgBox "No language selected!", vbOKOnly, "Error Language"
    
    ElseIf CheckBox1.Value = True Then
    Sheets("Offer NL").Select
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    ThisWorkbook.Path & "\offer\" & Number & " - " & Installer & " - " & Client & " - " & typ & (" NL ") & ".pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
    UserForm1.Hide
    
    End If
    
    If CheckBox2.Value = True Then
    Sheets("Offer FR").Select
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    ThisWorkbook.Path & "\offer\" & Number & " - " & Installer & " - " & Client & " - " & typ & (" FR ") & ".pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
    UserForm1.Hide
    
    End If
    
    If CheckBox3.Value = True Then
    Sheets("Offer ENG").Select
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    ThisWorkbook.Path & "\offer\" & Number & " - " & Installer & " - " & Client & " - " & typ & (" ENG ") & ".pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
    UserForm1.Hide
    
    End If
    
    Sheets("Main data").Select
    
    End Sub
    Last edited by vlady; 06-06-2014 at 09:53 PM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: 2 problems with creating a print button on a userform

    Thread posted in commercial services, hence closed.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Unfilled textboxes in userform creating problems.
    By barmfield in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-07-2012, 01:48 AM
  2. Print Button to print UserForm for multi-sheet
    By smartcard in forum Excel General
    Replies: 12
    Last Post: 04-29-2010, 07:47 AM
  3. Print button to print userform
    By jcarstens in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-20-2009, 08:18 PM
  4. Creating a print button for certain values
    By skylinekiller in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-30-2008, 12:35 PM
  5. Creating a Print Button
    By william4444 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 06-22-2006, 02:33 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1