Hi
I have a question about a macro I am creating in Excel.
The VB behind the button is as follows:- - Private Sub CommandButton1_Click()
-
-
Filename = Range("H66")
-
ActiveWorkbook.SaveAs Filename:=Filename
-
End Sub
This quite simply saves the file as the name shown in Cell h66.
What I now need to do is save it to a specific folder. Ie C drive / Estimates. How do I show this please.
Thanks
Jacc14
9 1476 Delerna 1,134
Recognized Expert Top Contributor
Something like this -
Filename = "c:/Estimates/" & Range("H66")
-
NeoPa 32,557
Recognized Expert Moderator MVP
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question and indeed the instructions in the posting window itself).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use the tags in future.
ADMIN.
ADezii 8,834
Recognized Expert Expert - Dim strFileName As String
-
Dim strFolderPath As String
-
-
strFileName = Range("H66")
-
strFolderPath = "C:\<Folder1>\<Folder2>\"
-
-
If Len(strFileName) > 0 Then
-
ActiveWorkbook.SaveAs Filename:=strFolderPath & strFileName
-
End If
NeoPa 32,557
Recognized Expert Moderator MVP
Something like this - Filename = "c:/Estimates/" & Range("H66")
I only noticed this after ADezii posted, but Excel is run mostly on Windows based machines, and for them you will need to use the backslash character (\) in place of the slash (/). It would then be (for your stated folder) : - Filename = "C:\Estimates\" & Range("H66")
Delerna 1,134
Recognized Expert Top Contributor
I only noticed this after ADezii posted, but Excel is run mostly on Windows based machines, and for them you will need to use the backslash character (\) in place of the slash (/). It would then be (for your stated folder) : - Filename = "C:\Estimates\" & Range("H66")
oops.
I use html, jscript, vbscript, vba ,c# , access, sql, db2 and various languages at home for 3D. I get syntax differences mixed sometimes. I appologise if it caused any confusion.
That'll tech me for posting before testing.
NeoPa 32,557
Recognized Expert Moderator MVP
Nah. Don't be silly.
I simple little mistake that I'm sure anyone would have spotted had they tried it out. Don't worry about it :)
ADezii 8,834
Recognized Expert Expert
After some serious thinking, scary isn't it, wouldn't this be a better solution for you? - Dim varFileName As Variant
-
Dim NewWorkbook As Workbook
-
-
Set NewWorkbook = Workbooks.Add
-
-
varFileName = Application.GetSaveAsFilename
-
-
If varFileName <> False Then
-
'For some odd reason, Dialog includes a "." at the end
-
'of a File's Name with no Extension
-
If Right$(varFileName, 3) <> "xls" Then
-
varFileName = varFileName & "xls"
-
End If
-
NewWorkbook.SaveAs Filename:=varFileName
-
End If
-
-
NewWorkbook.Close
-
ActiveWorkbook.Activate
Thanks everyone for your help. I have succeeded in what I was after
Best regards
Jacc14
NeoPa 32,557
Recognized Expert Moderator MVP
You're welcome, and thanks for letting us know :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mrs Howl |
last post by:
I don't know if there's even a way to do what I want. I click on a
button in an Access form, and it opens an instance of Excel, and opens
a workbook and runs a macro that's in it. So far, fine,...
|
by: Alex |
last post by:
i have a module in Access which opens an existing Excel file and
envokes a macro within the Excel file to draw graphs. now i am trying
to convert the Excel macro to an Access one so that the...
|
by: Nick M |
last post by:
Hello All,
Excellent info here Thanks!
I am very new to using access in general and I am on a learning curve.
I'm trying to import an excel workbook (with worksheets) into an access db
via a...
|
by: Rich Wallace |
last post by:
Is there a way to open an Excel file and either respond to or supress the
Macro warning window via VB.NET?
Dim oExcel As Excel.Workbook
Dim sFilePath As String = "C:\DailyReport.xls"
oExcel...
|
by: Mr.Doubt |
last post by:
I'm trying to run a Excel macro, which uses SOLVER.XLA Add-In, in
VB.NET application. When the macro is executed I get the following
error message
"Solver: An unexpected internal error occured,...
| |
by: Senthil |
last post by:
Hi All
I need to create an Excel report and create a command button and
have to run a macro on the
click event that will print all the pages in the Excel workbook.
I am able to create the report...
|
by: shara |
last post by:
Hello,
I have a php script that outputs an excel sheet.The user has to download macro every time he wants to run the macro on the excel sheet.
Is there anything in php where the code downloads...
|
by: Catbkr1 |
last post by:
I have to automatically create some Excel Spreadsheets based on automatically generated .CSV files that are produced overnight. Each .CSV has several columns that need to be deleted. The same...
|
by: mld01s |
last post by:
Hi all!!
I need help, I have been stuck for a few days on this one. I am trying to open an excel table from a command button in Access. The excel table has an auto_open macro, that is supposed to...
|
by: MitchR |
last post by:
Good Morning Folks;
I have a question that is pretty far fetched but here goes nothing... I am looking to find a way to insert a macro into an Excel command button located in an Access VBA...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |