473,395 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

basic CreateObject syntax question

Okay, so I got the common dialog working.

but how to create object to copy selected files?

Dim d As Object
Dim fDialog As Office.FileDialog

Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
Set d = CreateObject("FileSystemObject") '<<<=== ???
d.CopyFile varFile, strOrgDir
d.Close
Next
End If
Nov 12 '05 #1
7 5404
Try this ...

Dim objScript
Set objScript= CreateObject("Scripting.FileSystemObject")
objScript.CopyFile strSource, strTarget

--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"deko" <dj****@hotmail.com> wrote in message
news:uZ*******************@newssvr25.news.prodigy. com...
Okay, so I got the common dialog working.

but how to create object to copy selected files?

Dim d As Object
Dim fDialog As Office.FileDialog

Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
Set d = CreateObject("FileSystemObject") '<<<=== ???
d.CopyFile varFile, strOrgDir
d.Close
Next
End If

Nov 12 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Why not do this:

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
FileCopy varFile, strOrgDir & "\" & varFile
Next
End If

FileCopy is a built-in Access function.

- --
MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP9DnsIechKqOuFEgEQJd/gCdGtee4Dx7WmMbJVpvFOA+GdEW9SsAoK0C
CtpUqkTIu1p3T9XI4MIXA49e
=nnj3
-----END PGP SIGNATURE-----

deko wrote:
Okay, so I got the common dialog working.

but how to create object to copy selected files?

Dim d As Object
Dim fDialog As Office.FileDialog

Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
Set d = CreateObject("FileSystemObject") '<<<=== ???
d.CopyFile varFile, strOrgDir
d.Close
Next
End If

Nov 12 '05 #3
Ooops! You're right. How simple and clean!

Reminds me of something a doctor once said. When presented
with symptoms of an illness, always think simple, basic, instead
of strange and exotic.

"When you hear hoof-beats, think horses, not zebras."
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"MGFoster" <me@privacy.com> wrote in message
news:HI***************@newsread2.news.pas.earthlin k.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Why not do this:

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
FileCopy varFile, strOrgDir & "\" & varFile
Next
End If

FileCopy is a built-in Access function.

- --
MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP9DnsIechKqOuFEgEQJd/gCdGtee4Dx7WmMbJVpvFOA+GdEW9SsAoK0C
CtpUqkTIu1p3T9XI4MIXA49e
=nnj3
-----END PGP SIGNATURE-----

deko wrote:
Okay, so I got the common dialog working.

but how to create object to copy selected files?

Dim d As Object
Dim fDialog As Office.FileDialog

Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
Set d = CreateObject("FileSystemObject") '<<<=== ???
d.CopyFile varFile, strOrgDir
d.Close
Next
End If


Nov 12 '05 #4
Hi and thanks for the reply.

I tried this:

Dim objFile as Object
Set objFile = CreateObject("Scripting.FileSystemObject")
objFile.MoveFile strSource, strDestination
objFile.Close

and got:

Error Number 438: Object doesn't support this property or method

I also tried:

Dim objFile as Object
Set objFile = CreateObject("varFile.FileSystemObject")
objFile.MoveFile strSource, strDestination
objFile.Close

and that didn't work either...

Yes, I am trying to MoveFile now, rather than CopyFile, but the results are
the same either way.
"Danny J. Lesandrini" <dl*********@hotmail.com> wrote in message
news:bq*************@ID-82595.news.uni-berlin.de...
Try this ...

Dim objScript
Set objScript= CreateObject("Scripting.FileSystemObject")
objScript.CopyFile strSource, strTarget

--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"deko" <dj****@hotmail.com> wrote in message
news:uZ*******************@newssvr25.news.prodigy. com...
Okay, so I got the common dialog working.

but how to create object to copy selected files?

Dim d As Object
Dim fDialog As Office.FileDialog

Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
Set d = CreateObject("FileSystemObject") '<<<=== ???
d.CopyFile varFile, strOrgDir
d.Close
Next
End If


Nov 12 '05 #5
Yes, that works great - thanks! But, I also need to MoveFiles... Is there
an equivalent MoveFile? I did not find one in VB Help....

I tried this:

Dim objFile as Object
Set objFile = CreateObject("Scripting.FileSystemObject")
objFile.MoveFile strSource, strDestination
objFile.Close

and got:

Error Number 438: Object doesn't support this property or method

I also tried:

Dim objFile as Object
Set objFile = CreateObject("varFile.FileSystemObject")
objFile.MoveFile strSource, strDestination
objFile.Close

and that didn't work either...

"MGFoster" <me@privacy.com> wrote in message
news:HI***************@newsread2.news.pas.earthlin k.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Why not do this:

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
FileCopy varFile, strOrgDir & "\" & varFile
Next
End If

FileCopy is a built-in Access function.

- --
MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP9DnsIechKqOuFEgEQJd/gCdGtee4Dx7WmMbJVpvFOA+GdEW9SsAoK0C
CtpUqkTIu1p3T9XI4MIXA49e
=nnj3
-----END PGP SIGNATURE-----

deko wrote:
Okay, so I got the common dialog working.

but how to create object to copy selected files?

Dim d As Object
Dim fDialog As Office.FileDialog

Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
Set d = CreateObject("FileSystemObject") '<<<=== ???
d.CopyFile varFile, strOrgDir
d.Close
Next
End If


Nov 12 '05 #6
Ah ha...

It's working like a champ now...

The problem was objFile.Close - apparently I don't need to Close this?
"deko" <dj****@hotmail.com> wrote in message
news:Ed*******************@newssvr25.news.prodigy. com...
Hi and thanks for the reply.

I tried this:

Dim objFile as Object
Set objFile = CreateObject("Scripting.FileSystemObject")
objFile.MoveFile strSource, strDestination
objFile.Close

and got:

Error Number 438: Object doesn't support this property or method

I also tried:

Dim objFile as Object
Set objFile = CreateObject("varFile.FileSystemObject")
objFile.MoveFile strSource, strDestination
objFile.Close

and that didn't work either...

Yes, I am trying to MoveFile now, rather than CopyFile, but the results are the same either way.
"Danny J. Lesandrini" <dl*********@hotmail.com> wrote in message
news:bq*************@ID-82595.news.uni-berlin.de...
Try this ...

Dim objScript
Set objScript= CreateObject("Scripting.FileSystemObject")
objScript.CopyFile strSource, strTarget

--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"deko" <dj****@hotmail.com> wrote in message
news:uZ*******************@newssvr25.news.prodigy. com...
Okay, so I got the common dialog working.

but how to create object to copy selected files?

Dim d As Object
Dim fDialog As Office.FileDialog

Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
Set d = CreateObject("FileSystemObject") '<<<=== ???
d.CopyFile varFile, strOrgDir
d.Close
Next
End If



Nov 12 '05 #7
objFile.Close was the culprit...

I figured this out after discovering the F8 key....

as an aside, it seems I need to put in a breakpoint, then click the sub's
command button on the form in order to step through the sub with F8 - is
there a way step through the sub from within the IDE? When I go to Debug >>
Step Into (or just hit F8 withing the IDE)... nothing happens.

(I get some kind of macro window when trying Run >> Run Sub/User Form)

"deko" <dj****@hotmail.com> wrote in message
news:sh*******************@newssvr25.news.prodigy. com...
Yes, that works great - thanks! But, I also need to MoveFiles... Is there
an equivalent MoveFile? I did not find one in VB Help....

I tried this:

Dim objFile as Object
Set objFile = CreateObject("Scripting.FileSystemObject")
objFile.MoveFile strSource, strDestination
objFile.Close

and got:

Error Number 438: Object doesn't support this property or method

I also tried:

Dim objFile as Object
Set objFile = CreateObject("varFile.FileSystemObject")
objFile.MoveFile strSource, strDestination
objFile.Close

and that didn't work either...

"MGFoster" <me@privacy.com> wrote in message
news:HI***************@newsread2.news.pas.earthlin k.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Why not do this:

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
FileCopy varFile, strOrgDir & "\" & varFile
Next
End If

FileCopy is a built-in Access function.

- --
MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP9DnsIechKqOuFEgEQJd/gCdGtee4Dx7WmMbJVpvFOA+GdEW9SsAoK0C
CtpUqkTIu1p3T9XI4MIXA49e
=nnj3
-----END PGP SIGNATURE-----

deko wrote:
Okay, so I got the common dialog working.

but how to create object to copy selected files?

Dim d As Object
Dim fDialog As Office.FileDialog

Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

If fDialog.Show = True Then
For Each varFile In fDialog.SelectedItems
Set d = CreateObject("FileSystemObject") '<<<=== ???
d.CopyFile varFile, strOrgDir
d.Close
Next
End If



Nov 12 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Alex Ang | last post by:
I have written the following VBScript program. It is stored into a file "map_drive.vbs". It successfully mapped to a network drive \\server1\data. Dim WshNetwork Set WshNetwork =...
2
by: Eli | last post by:
Hi gurus, My question is about exchanging data on a basic HTML page between a JavaScript piece of code and a Java client-side <APPLET> residing on the same webpage. To demonstrate the idea of...
3
by: deko | last post by:
When adding Outlook Appointment Items from Access, should I use: Set ol = New Outlook.Application --or-- Set ol = CreateObject("Outlook.Application") Outlook seems to crash either way. The...
7
by: gerryLowry::Ability Business Computer Services {KC | last post by:
"Getting Back Your Visual Basic 6.0 Goodies" by Billy Hollis, 2003-5-14, states: "Getting a Forms Collection Visual Basic 6.0 developers are often fond of looping through the currently loaded...
13
by: usenet | last post by:
How and where can one find out about the basics of VB/Access2003 syntax? I am a died in the wool C/C++/Java Linux/Unix programmer and I am finding it difficult to understand the program format...
1
by: Lou Civitella | last post by:
I have found code that Recycles the Application Pool but it was written in VBScript can anyone convert this for me to VB.Net? Thanks! 'Appendix B: Application Pool Recycle script - Save as...
6
by: John Bailo | last post by:
http://www.informationweek.com/software/showArticle.jhtml?articleID=196600515 Developers Embrace Java, Drop Visual Basic "Developers have abandoned Microsoft's Visual Basic in droves during...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
0
by: stevedls | last post by:
Hello and thanks for your help, I am using Word and Visual basic 6.3, I am not a professional programmer but have gotten some basic stuff done using help menus and books however finding anything...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
agi2029
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.