defined object

D

dan

I am getting a Compile error: message with the following Macro which was
working before.
The macro was to backup a folder "shortxls" as "shortxlsmmddyy"

Sub MDshortxlsmmddyy()
Dim myOldFolder As String
Dim myNewFolder1 As String
Dim datecode As String
Dim FSO As Scripting.FileSystemObject
' The statement above kick out an error "User-defined type not defined"
datecode = Format(Date, "mmddyy")
Set FSO = New Scripting.FileSystemObject
myOldFolder = "D:\Documents and Settings\Dan\Desktop\shortxls"
myNewFolder1 = "D:\MyBackup\all shortxls\shortxls" & datecode
If FSO.FolderExists(myOldFolder) Then
If FSO.FolderExists(myNewFolder1) = False Then
FSO.CopyFolder Source:=myOldFolder, _
Destination:=myNewFolder1
Else
MsgBox "Not Copied in all shortxls!"
End If
End If
End Sub

Please Help,
Thanks
 
G

Guest

Dim FSO As Scripting.FileSystemObject

Maybe the code was written in a later version of Excel than what you are
using? Was this a new type in XL2003?

Using XL2000 I have to use
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
 
D

Dave Peterson

Make sure you have a reference to Microsoft Scripting Runtime (under
Tools|References in the VBE).

I'm betting that you copied the code from one workbook (with the reference) to a
different workbook that doesn't have that reference (yet!).
 
D

dan

Hi Dave,
Here is my history. My computer crushed. I restored it back to factory
condition.
Downloaded updates from Microsoft. I was setting up all my Excel files
references, until I encountered the object problem.

I changed the option to competible with previous version. I also enabled
Microsoft
Firewall in Excel. But I left Norton Firewall on. At each opening Excel, it
was
requesting a virus scan, but never finished it, even after several restart
attempts.

I removed the Office XP through Add/Remove and re-install it from the disk.
Now all I get is the Excel background with no contents, not even requesting
a
virus scan. Always said "ready" in the status bar.

Who might be able to help me? Desperately, Thanks
 
D

Dave Peterson

I don't use Norton, but I'd suggest disabling it (just temporarily) to see if
that helped.
 
D

Dave Peterson

And you're sure that the workbook isn't opening?

If you hit file|print preview, can you see anything?

If you can, maybe the window is just off the screen.

Window|arrange|tiled (and resize manually)

But I'm pretty much out of ideas.
No, it didn't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top