Results 1 to 2 of 2

Thread: need code for save button, to take text from textbox1 and use a filename.

  1. #1
    Neophyte Nutsy's Avatar
    Join Date
    Jul 2018
    Posts
    1
    Articles
    0
    Excel Version
    2016

    need code for save button, to take text from textbox1 and use a filename.



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I am having a problem finding the code to take the text from textbox1, as in the photo and using the txt as a file name when I print to pdf. Can anyone help please. Thanks in advance or if someone could suggest an all in one save and print button that would even be better.

    Click image for larger version. 

Name:	1.png 
Views:	10 
Size:	34.6 KB 
ID:	8162

  2. #2
    Conjurer Logit's Avatar
    Join Date
    Nov 2016
    Posts
    166
    Articles
    0
    Excel Version
    2007
    .
    Try this. Saves to same location as workbook :

    Code:
    Option Explicit
    
    
    Sub Export_Worksheet_to_PDF()
    
    
        Dim mypath As String, fname As String, dname As String
        mypath = ThisWorkbook.Path
        dname = Format(ActiveSheet.Range("B1").Value)
        fname = CreateObject("Scripting.FileSystemObject").GetBaseName(dname)
        ActiveSheet.Range("B3:G17").ExportAsFixedFormat 0, mypath & "\" & fname
    
    
    End Sub
    Attached Files Attached Files

Posting Permissions

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