- Function outfile()
-
Dim stbl As String
-
stbl = "Contact"
-
DoCmd.OutputTo acOutputTable, stbl, acFormatXLS, "c:\temp\contact_" & Format(Now(), "yyyymmdd") & "_" & Format(Time(), "hhmmss") & ".xls"
-
MsgBox "File Exported"
-
End Function
-
Exported Filename: contact_2007102 9_104206.xls
Question? How do I copy (VBA code) the Exported filename to a different location?
Thanks.
7 3888
How do I copy (VBA code) the Exported filename to a different location?
You can change your code slightly, like this: - Function outfile()
-
Dim stbl As String
-
Dim FileName as String
-
-
stbl = "Contact"
-
-
FileName = "contact_" & Format(Now(), "yyyymmdd") & "_" & Format(Time(), "hhmmss") & ".xls"
-
-
DoCmd.OutputTo acOutputTable, stbl, acFormatXLS, "c:\temp\" & FileName
-
-
'Copy to a different location
-
DoCmd.OutputTo acOutputTable, stbl, acFormatXLS, "d:\temp\" & FileName
-
-
-
MsgBox "File Exported"
-
End Function
-
and you'd have your filename as it was for the output file, right down to the second. But where do want to "copy" it to?
Linq ;0)>
To another location like a backup external hardrive.
What about file scripting? (see code below). With this code it is basically copying file from one source (c:\temp) to a new destination (c:\temp\txt), but i am getting error "Path not found". Thanks. -
Function copyfile()
-
Dim fs As Object
-
Dim oldPath As String, newPath As String
-
-
oldPath = "C:\Temp\contact_" & Format(Now(), "yyyymmdd") & "_" & Format(Time(), "hhmmss") & ".xls"
-
newPath = "C:\Temp\txt\contact_" & Format(Now(), "yyyymmdd") & "_" & Format(Time(), "hhmmss") & ".xls"
-
-
Set fs = CreateObject("Scripting.FileSystemObject")
-
-
fs.copyfile oldPath & "\" & "contact_" & Format(Now(), "yyyymmdd") & "_" & Format(Time(), "hhmmss") & ".xls", newPath & "\" & "contact_" & Format(Now(), "yyyymmdd") & "_" & Format(Time(), "hhmmss") & ".xls"
-
-
Set fs = Nothing
-
End Function
-
So you don't want to copy the filename to another location, as you said, but rather copy the file to another location. Go back to my previous post, where I've edited my code. Line # 12 repeats your operation, sending the file to the D drive and same subfolder as the original. You can modify this path to suit your needs. That's all you need to do.
Linq ;0)> Rabbit 12,516
Recognized Expert Moderator MVP
This is more efficient for copying a file: -
FileCopy "Source Path", "Destination Path"
-
This is slightly more efficient as far as formatting the date goes: -
Format(Now(), "yyyymmdd_hhmmss")
-
I think I will stick to your suggestion.. I don't to do tidious coding.. like the old saying "Work Smart Not Hard".. Thanks for all the inputs! =)
Rabbit 12,516
Recognized Expert Moderator MVP Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Anna |
last post by:
Hi all.
I am trying to write a stylesheet that will structure the input HTML
file in the following way:
For each heading of level n it needs to enclose the heading and all
its content until the next heading of the same level within the level
tag.
Example
input file:
|
by: ma740988 |
last post by:
There's no way to use the STL algorithm copy to print an outfile
(essentially an ofstream)? So now:
int main()
{
std::ifstream InFile( "exercise15.txt");
std::ofstream ToFile( "NewFile.txt" );
////////////////////////////
// Alternative 1
|
by: wutongjoe |
last post by:
Hi all,
I was writting 2 programs in c++ using linux.Say,one is app1 and another
one is app2,the app1 will generate 100 random numbers and then print
them on the standard output,and then the app2 needs to copy the numbers
from the standard output to its int array by doing this way: $ app1|app2
(a pipe ? I am a newbi,and not sure how to call...
|
by: Harag |
last post by:
Hi all
If I create an object with the following:
var ob1 = new objMyDefinedObject();
then I assign it to a new variable.
var ob2 = ob1
|
by: F. Michael Miller |
last post by:
I'd like to copy the listing of a directory (& sub directories) to a text
file in vb.net.
I'm looking for teh equivilant of the DOS command dir /s >
TargetFile.txt.
Thanks!
| |
by: Harrie |
last post by:
Hi group,
I want to indent existing XML files so they are more readable (at least
to me). At this moment I'm looking at the XML files OpenOffice.org's
Writer application produces in it's zipped "SXW" format (and they're one
line, probably to save space, which I find hard to read). At first I
thought I was going to do it with sed/awk or...
|
by: JurgenvonOerthel |
last post by:
Consider the classes Base, Derived1 and Derived2. Both Derived1 and
Derived2 derive publicly from Base.
Given a 'const Base &input' I want to initialize a 'const Derived1
&output'.
If the dynamic type of 'input' is Derived1, then 'output' should
become a reference to 'input'.
Otherwise 'output' should become a reference to the (temporary)...
|
by: Herman.Schultz |
last post by:
Hi,
How can I use iostream library in c++ to copy a file from i th byte
to an output file?
Thank you.
|
by: ajc308 |
last post by:
I'm attempting to sort the <file>s within each <directory> in my XML according to their file extension, then write out the resulting sorted data back to XML format. I had it working before, and when I opened up the file the next day, the XSL behaved completely different. I don't know if I accidentally changed something, but I can't see any...
|
by: Dijkstra |
last post by:
Hi folks!
First, this is the code I'm using to expose the problem:
------------------------------------------------------------------
#include <functional>
#include <string>
#include <iostream>
using namespace std;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |