Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2017, 04:14 AM
chemtoli chemtoli is offline How to save Excel file by field name as filename Windows 7 32bit How to save Excel file by field name as filename Office 2007
Novice
How to save Excel file by field name as filename
 
Join Date: Jan 2017
Posts: 5
chemtoli is on a distinguished road
Default How to save Excel file by field name as filename

For example I need to save a Excel doc by Costumer Number (example; David Hass) and Request Number (example: 001-17) so when I click on button Save by CN & RN, my Excel file should be saved on Desktop by name David Hass 001-17. Please see attachment


Reply With Quote
  #2  
Old 01-20-2017, 09:35 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline How to save Excel file by field name as filename Windows 7 64bit How to save Excel file by field name as filename Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,779
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

No attachments visible...
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #3  
Old 01-21-2017, 04:02 PM
jolivanes jolivanes is offline How to save Excel file by field name as filename Windows XP How to save Excel file by field name as filename Office 2007
Advanced Beginner
 
Join Date: Sep 2011
Posts: 93
jolivanes will become famous soon enough
Default

I noticed that both the Customer Number and Request Number are in Sheet1 in Cells(4, 2) = B4 and in Cells(2, 5) = E2
If you change that, you need to change these references also.
Code:
Sub Maybe()
    Dim wb1 As Workbook, wbName As String, j As Long
    Application.ScreenUpdating = False
    Set wb1 = ThisWorkbook
    wbName = wb1.Sheets("Sheet1").Cells(4, 2).Value & " " & wb1.Sheets("Sheet1").Cells(2, 5).Value
    ActiveWorkbook.SaveAs Filename:=CreateObject("WScript.Shell").Specialfolders("Desktop") & "\" & wbName, _
    FileFormat:=xlOpenXMLWorkbookMacroEnabled
    ActiveWorkbook.Close
  Application.ScreenUpdating = True
End Sub
Reply With Quote
  #4  
Old 01-22-2017, 05:34 AM
chemtoli chemtoli is offline How to save Excel file by field name as filename Windows 7 32bit How to save Excel file by field name as filename Office 2007
Novice
How to save Excel file by field name as filename
 
Join Date: Jan 2017
Posts: 5
chemtoli is on a distinguished road
Default

Dear jolivanes,

Attached please find my excel file maybe this helps you understand what I really want.

Anyway I appreciate your help.

Kind regards
Attached Files
File Type: xlsx David Hass 001-17.xlsx (9.5 KB, 10 views)
Reply With Quote
  #5  
Old 01-22-2017, 08:32 AM
jolivanes jolivanes is offline How to save Excel file by field name as filename Windows XP How to save Excel file by field name as filename Office 2007
Advanced Beginner
 
Join Date: Sep 2011
Posts: 93
jolivanes will become famous soon enough
Default

Code:
Sub Maybe()
    Dim wb1 As Workbook, wbName As String, j As Long
    Application.ScreenUpdating = False
    Set wb1 = ThisWorkbook
    wbName = wb1.Sheets("Sheet1").Cells(4, 3).Value & " " & wb1.Sheets("Sheet1").Cells(5, 3).Value
    ActiveWorkbook.SaveAs Filename:=CreateObject("WScript.Shell").Specialfolders("Desktop") & "\" & wbName, _
    FileFormat:=xlOpenXMLWorkbookMacroEnabled
    ActiveWorkbook.Close
  Application.ScreenUpdating = True
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to save Excel file by field name as filename How can I save a Word Document as a PDF file with a merged field filename? kp2009 Word VBA 5 08-27-2015 11:45 PM
Excel connot open file (filename) xlsx dengeorge6 Excel 0 12-12-2014 01:36 AM
Save Filename based on Text Field madcar86 Word VBA 8 10-19-2014 12:53 AM
How to save Excel file by field name as filename Auto update Filename field Oliver Beirne Word VBA 4 10-19-2012 03:33 AM
How to save Excel file by field name as filename Save Filename using Document Text Knawl Word 11 10-10-2011 03:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft