+ Reply to Thread
Results 1 to 10 of 10

Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

Hybrid View

Anthony Glenn Macro Open Excel from... 08-11-2022, 01:12 PM
Bernie Deitrick Re: Macro Open Excel from... 08-11-2022, 04:11 PM
Anthony Glenn Re: Macro Open Excel from... 08-11-2022, 04:53 PM
Bernie Deitrick Re: Macro Open Excel from... 08-12-2022, 10:31 AM
beyond Excel Re: Macro Open Excel from... 08-11-2022, 04:47 PM
Anthony Glenn Re: Macro Open Excel from... 08-12-2022, 03:16 PM
beyond Excel Re: Macro Open Excel from... 08-12-2022, 03:47 PM
Anthony Glenn Re: Macro Open Excel from... 08-15-2022, 06:35 PM
beyond Excel Re: Macro Open Excel from... 08-15-2022, 07:34 PM
Anthony Glenn Re: Macro Open Excel from... 08-15-2022, 07:40 PM
  1. #1
    Registered User
    Join Date
    08-11-2022
    Location
    Woodland Hills, CA
    MS-Off Ver
    365
    Posts
    5

    Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

    Hello Forum,

    I need help writing a macro/VBA code to open an Excel file saved in a File Explorer folder, then take a specific Tab from the Excel file and save it as a .prn file in a different File Explorer folder.
    Much appreciated. Please let me know if you need any additional info.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

    Do the file, source folder, target folder, or tab ever change? OR are all those things variable, and need to be chosen by the user at the time the macro runs?
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    08-11-2022
    Location
    Woodland Hills, CA
    MS-Off Ver
    365
    Posts
    5

    Re: Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

    Hello Bernie,

    The source folder and target folder will always be the same. Tab names to be saved as .prn will also be the same. Only the file name will vary each time. I can have one Excel file in the source folder at a given time so the code could choose the one file in the source folder.

    Thank you for your time, AG
    Last edited by Anthony Glenn; 08-11-2022 at 05:06 PM.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

    You should be able to use the macro (with some modifications) posted by "beyond Excel"

  5. #5
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

    I show you a way to do it:

    Sub Extract_and_Save_as_PRN()
    Dim mPath, wb As Workbook
    mPath = "Select a file type *.xl*"
    If MsgBox(mPath, vbOKCancel) = vbCancel Then Exit Sub
    mPath = Application.GetOpenFilename("Excel Files (*.xl*), *.xl*", Title:=mPath)
    If mPath = False Then Exit Sub
    Set wb = Workbooks.Open(mPath, ReadOnly:=True)
    Set mPath = Nothing: On Error Resume Next
    Set mPath = Application.InputBox("Select any cell in the sheet to extract", Type:=8)
    If mPath Is Nothing Then
      wb.Close False
      End
    End If
    On Error GoTo 0
    Application.ScreenUpdating = False: DoEvents
    mPath.Parent.Copy
    mPath = ThisWorkbook.Path & "\" & ActiveSheet.Name & ".prn"
    If Dir(mPath) <> "" Then
      Kill mPath
      Application.Wait DateAdd("s", 1, Now)
    End If
    ActiveWorkbook.SaveAs mPath, FileFormat:=xlTextPrinter
    ActiveWorkbook.Close False
    wb.Close False
    MsgBox "Saved file '" & mPath & "'"
    End
    End Sub

  6. #6
    Registered User
    Join Date
    08-11-2022
    Location
    Woodland Hills, CA
    MS-Off Ver
    365
    Posts
    5

    Re: Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

    Hi again, thank you for your help. I would to streamline this workflow: from within the Excel file itself, I would simply like for the macro to first find the tab named "Title" and another tab named "Script" and save each tab as individual .prn files with different file names "TitleABC.prn" and "ScriptABC.prn" in a specific specified folder (always same location). Additionally, can the macro be launched by typing "Ctrl-T"?

  7. #7
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

    Quote Originally Posted by Anthony Glenn View Post
    Hi again, thank you for your help.
    Who are you referring to in your message?...

  8. #8
    Registered User
    Join Date
    08-11-2022
    Location
    Woodland Hills, CA
    MS-Off Ver
    365
    Posts
    5

    Re: Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

    Thanks in advance, beyond Excel. If you could help with the coding, I would very much appreciate it. AG

  9. #9
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

    Quote Originally Posted by Anthony Glenn View Post
    Thanks in advance, beyond Excel. If you could help with the coding, I would very much appreciate it. AG
    I don't understand:
    - Did you see the code of my message #3?
    - Do you want me to help you with some of said code?...

  10. #10
    Registered User
    Join Date
    08-11-2022
    Location
    Woodland Hills, CA
    MS-Off Ver
    365
    Posts
    5

    Re: Macro Open Excel from FileExplorer, Save Tab as .prn File in different Folder

    Hello beyond Excel, yes, may I ask for help with the code you provided? From within the Excel file itself, I would simply like for the macro to first find the tab named "Title" and another tab named "Script" and save each tab as individual .prn files with different file names "TitleABC.prn" and "ScriptABC.prn" in a specific specified folder (always same location). Additionally, can the macro be launched by typing "Ctrl-T"?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 8
    Last Post: 12-02-2019, 03:42 PM
  2. [SOLVED] Macro to open an Excel workbook and save to another folder
    By Hoover5896 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2017, 09:28 PM
  3. Save open file regardless of the folder where it is
    By pedroc74 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2017, 07:17 AM
  4. [SOLVED] VBA Create open & then save as excel file in folder
    By sagar007 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-20-2013, 05:04 AM
  5. exce; macro to open, save embedded pdf, word, excel, ppt files to a folder
    By mcledavid in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-16-2009, 05:17 PM
  6. open file from folder save in new folder
    By tim64 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 06-17-2005, 03:19 PM

Tags for this Thread

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