Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2023, 05:41 PM
Jmon Jmon is offline Saving file with variable in file name Windows 11 Saving file with variable in file name Office 2019
Novice
Saving file with variable in file name
 
Join Date: May 2023
Posts: 1
Jmon is on a distinguished road
Default Saving file with variable in file name

I am attempting to create a bunch files from a pivot table using VBA. I'm running into a problem wherein the variable is not working when saving the file.

To obtain the variable, at the start of the macro, I am using a input box. That code sits at the top of the macro, in the same module as the remaining sub's. That code:



Dim vReport_Date As String
vReport_Date = Application.InputBox("Enter Date", "Enter Report Date", "")

Then in each sub macro I am attempting to use that variable in the file name with the following code:

ActiveWorkbook.SaveAs Filename:="{Path listed here}\{set part of file name here} " & vReport_Date, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

The file is saving; however, the variable does not appear. Rather it saves as just the set part of the file name

Any suggestions would be greatly appreciated.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
saving a file Beebop Word 1 08-30-2017 09:20 PM
Saving file with variable in file name Split file using variable delimiter kramer74 Word VBA 7 09-01-2014 12:12 AM
Word does not ask do i want to overwrite a file on saving a file sam2149 Word 2 03-24-2014 04:18 AM
Saving file with variable in file name Saving mpp file as XML OTPM Project 7 02-26-2014 07:22 AM
switching windows for variable file name jillapass Word VBA 1 04-21-2012 02:59 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:34 PM.


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