ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   defined object (https://www.excelbanter.com/excel-discussion-misc-queries/99399-defined-object.html)

dan

defined object
 
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



JMB

defined object
 
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")

"dan" wrote:

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




Dave Peterson

defined object
 
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!).



dan wrote:

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


--

Dave Peterson

dan

defined object
 
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

"Dave Peterson" wrote in message
...
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!).



dan wrote:

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


--

Dave Peterson




Dave Peterson

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



dan wrote:

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

"Dave Peterson" wrote in message
...
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!).



dan wrote:

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


--

Dave Peterson


--

Dave Peterson

dan

defined object
 
No, it didn't.

"Dave Peterson" wrote in message
...
I don't use Norton, but I'd suggest disabling it (just temporarily) to see
if
that helped.



dan wrote:

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

"Dave Peterson" wrote in message
...
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!).



dan wrote:

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

--

Dave Peterson


--

Dave Peterson




Dave Peterson

defined object
 
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.

dan wrote:

No, it didn't.

"Dave Peterson" wrote in message
...
I don't use Norton, but I'd suggest disabling it (just temporarily) to see
if
that helped.



dan wrote:

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

"Dave Peterson" wrote in message
...
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!).



dan wrote:

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

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com