PC Review


Reply
Thread Tools Rate Thread

Copy to a flash drive

 
 
ypukpete
Guest
Posts: n/a
 
      23rd Dec 2008
i am using Excel 2003. I am looking for VBA code which I can use with a
command button which will open the Copy-to Window so that I can copy the
workbook I have open to a Flash Drive in a USB port. All help gratefully
accepted
Thanks.
--
ypukpete
 
Reply With Quote
 
 
 
 
FSt1
Guest
Posts: n/a
 
      23rd Dec 2008
hi
i use 2003 also. here is the code i use to save to my flash drive. the code
lists my flash drive as G. your's may be different.
saving to the flash drive takes a while almost like saving to the old time
floppy disks. don't know why. it's faster to transfer the file vis explorer
but that is rather manual.
Sub FlashSave()
Application.DisplayAlerts = False
Application.StatusBar = "Saving to Flash"
ChDir "G:\Excel"

ActiveWorkbook.SaveAs Filename:="G:\Excel\Expences2008.xls",
FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _

ReadOnlyRecommended:=False ,_
CreateBackup:=False

Application.StatusBar = "saving to c drive"

ChDir "C:\Documents and Settings\FSt1\My Documents\XL"

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\FSt1\My Documents\XL\Expences2008.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:= False, CreateBackup:=False

Application.DisplayAlerts = True
Application.StatusBar = False
MsgBox "Finished Saving."
End Sub

regards
FSt1


"ypukpete" wrote:

> i am using Excel 2003. I am looking for VBA code which I can use with a
> command button which will open the Copy-to Window so that I can copy the
> workbook I have open to a Flash Drive in a USB port. All help gratefully
> accepted
> Thanks.
> --
> ypukpete

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      23rd Dec 2008
I would never save a file to removable media. Save the file and use COPY or
FILECOPY to copy to the flash.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"ypukpete" <(E-Mail Removed)> wrote in message
news:9D9F52C3-0A38-4938-9CB2-(E-Mail Removed)...
>i am using Excel 2003. I am looking for VBA code which I can use with a
> command button which will open the Copy-to Window so that I can copy the
> workbook I have open to a Flash Drive in a USB port. All help gratefully
> accepted
> Thanks.
> --
> ypukpete


 
Reply With Quote
 
JMay
Guest
Posts: n/a
 
      23rd Dec 2008
So can this be done withing Excel VBA - Would you do it differently from
FSt1's code?

"Don Guillett" wrote:

> I would never save a file to removable media. Save the file and use COPY or
> FILECOPY to copy to the flash.
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "ypukpete" <(E-Mail Removed)> wrote in message
> news:9D9F52C3-0A38-4938-9CB2-(E-Mail Removed)...
> >i am using Excel 2003. I am looking for VBA code which I can use with a
> > command button which will open the Copy-to Window so that I can copy the
> > workbook I have open to a Flash Drive in a USB port. All help gratefully
> > accepted
> > Thanks.
> > --
> > ypukpete

>
>

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      23rd Dec 2008
If I understand correctly, you can use either of the following
procedures to copy the workbook ThisWorkbook to a flash drive,
assuming you know the drive letter of the flash drive.


Sub AAA()
Dim SaveFileName As Variant
Dim FlashDrive As String
FlashDrive = "K:\"
SaveFileName = Application.GetSaveAsFilename(FlashDrive, _
"Excel Files (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm")
If SaveFileName = False Then
Debug.Print "cancelled"
Else
ThisWorkbook.SaveCopyAs SaveFileName
End If
End Sub

Sub BBB()
Dim FlashDrive As String
FlashDrive = "K:\"
With ThisWorkbook
.ChangeFileAccess xlReadOnly
FileCopy ThisWorkbook.FullName, FlashDrive & "\" & _
ThisWorkbook.Name
.ChangeFileAccess xlReadWrite
End With
End Sub

As an alternative, you can display a Browse Folder dialog to the user,
let him pick the root of the flash drive and SaveCopyAs to that
folder. E.g.,

Sub CCC()
Dim FolderName As String
FolderName = BrowseFolder("Select the flash drive's root.")
If FolderName = vbNullString Then
Debug.Print "cancel"
Else
ThisWorkbook.SaveCopyAs FolderName & "\" & ThisWorkbook.Name
End If

End Sub

The BrowseFolder function is described at
http://www.cpearson.com/excel/BrowseFolder.aspx

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Mon, 22 Dec 2008 17:59:00 -0800, ypukpete
<(E-Mail Removed)> wrote:

>i am using Excel 2003. I am looking for VBA code which I can use with a
>command button which will open the Copy-to Window so that I can copy the
>workbook I have open to a Flash Drive in a USB port. All help gratefully
>accepted
>Thanks.

 
Reply With Quote
 
ypukpete
Guest
Posts: n/a
 
      23rd Dec 2008
Thanks guys for all your help,
I tried FSt 1's code but had problems getting it to work correctly (must
have been doing something wrong)...but thanks for your help FSt1. I tried
Chip's first method and it is just what I wanted.
Wishing you all a merry christmas.
--
ypukpete


"Chip Pearson" wrote:

> If I understand correctly, you can use either of the following
> procedures to copy the workbook ThisWorkbook to a flash drive,
> assuming you know the drive letter of the flash drive.
>
>
> Sub AAA()
> Dim SaveFileName As Variant
> Dim FlashDrive As String
> FlashDrive = "K:\"
> SaveFileName = Application.GetSaveAsFilename(FlashDrive, _
> "Excel Files (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm")
> If SaveFileName = False Then
> Debug.Print "cancelled"
> Else
> ThisWorkbook.SaveCopyAs SaveFileName
> End If
> End Sub
>
> Sub BBB()
> Dim FlashDrive As String
> FlashDrive = "K:\"
> With ThisWorkbook
> .ChangeFileAccess xlReadOnly
> FileCopy ThisWorkbook.FullName, FlashDrive & "\" & _
> ThisWorkbook.Name
> .ChangeFileAccess xlReadWrite
> End With
> End Sub
>
> As an alternative, you can display a Browse Folder dialog to the user,
> let him pick the root of the flash drive and SaveCopyAs to that
> folder. E.g.,
>
> Sub CCC()
> Dim FolderName As String
> FolderName = BrowseFolder("Select the flash drive's root.")
> If FolderName = vbNullString Then
> Debug.Print "cancel"
> Else
> ThisWorkbook.SaveCopyAs FolderName & "\" & ThisWorkbook.Name
> End If
>
> End Sub
>
> The BrowseFolder function is described at
> http://www.cpearson.com/excel/BrowseFolder.aspx
>
> Cordially,
> Chip Pearson
> Microsoft MVP
> Excel Product Group
> Pearson Software Consulting, LLC
> www.cpearson.com
> (email on web site)
>
>
> On Mon, 22 Dec 2008 17:59:00 -0800, ypukpete
> <(E-Mail Removed)> wrote:
>
> >i am using Excel 2003. I am looking for VBA code which I can use with a
> >command button which will open the Copy-to Window so that I can copy the
> >workbook I have open to a Flash Drive in a USB port. All help gratefully
> >accepted
> >Thanks.

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: how does copy files from a flash drive? Michael Walraven Windows Vista File Management 2 17th Feb 2010 10:05 PM
Re: how does copy files from a flash drive? R. C. White Windows Vista File Management 0 5th Feb 2010 02:55 AM
copy data to a flash drive brummyfan Windows XP Help 3 9th Jan 2008 05:47 PM
copy order to flash drive Jim Windows XP General 1 8th Mar 2007 07:44 PM
Image Copy of Flash Drive Will Windows XP Hardware 1 30th Jun 2006 02:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:29 AM.