- 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_20071029_104206.xls
Question? How do I copy (VBA code) the Exported filename to a different location?
Thanks.
7 3882
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...
|
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"...
|
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...
|
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...
|
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...
|
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...
|
by: Dijkstra |
last post by:
Hi folks!
First, this is the code I'm using to expose the problem:
------------------------------------------------------------------
#include <functional>
#include <string>
#include...
|
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,...
| |
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: 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...
|
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: 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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |