Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Unable to Compile a Macro

Hi ,
I am trying to compile the following code.But iam getting the following error:
Error
*****
User Defined Type not define :
Public fso As New Scripting.FileSystemObject
*****
Code
*****
Option Explicit

Public fso As New Scripting.FileSystemObject

Public vertView As Boolean


Public Sub Auto_Open()
On Error GoTo ErrorHandler

Dim newMenu As Menu, menuName As String


menuName = Application.MenuBars(xlWorksheet).Menus("MainMenu" ).Caption

Exit Sub
ErrorHandler:
If Err.Number = 1004 Then
Set newMenu =
Application.MenuBars(xlWorksheet).Menus.Add("&Main Menu", _
Application.MenuBars(xlWorksheet).Menus.Count)

newMenu.MenuItems.Add "E&xport Data File ...", "ExportToFile"
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Unable to Compile a Macro

First, make sure you set a reference to "Microsoft Scripting Runtime"
(Under Tools|References)

But there's nothing in your posted code that uses FSO.

Second, Chip Pearson explains why it's not good to use:

Dim Something As New SomeObject
he
http://www.cpearson.com/excel/DeclaringVariables.aspx
look for
Don't Use Auto-Instancing Object Variables








Bobby wrote:

Hi ,
I am trying to compile the following code.But iam getting the following error:
Error
*****
User Defined Type not define :
Public fso As New Scripting.FileSystemObject
*****
Code
*****
Option Explicit

Public fso As New Scripting.FileSystemObject

Public vertView As Boolean

Public Sub Auto_Open()
On Error GoTo ErrorHandler

Dim newMenu As Menu, menuName As String


menuName = Application.MenuBars(xlWorksheet).Menus("MainMenu" ).Caption

Exit Sub
ErrorHandler:
If Err.Number = 1004 Then
Set newMenu =
Application.MenuBars(xlWorksheet).Menus.Add("&Main Menu", _
Application.MenuBars(xlWorksheet).Menus.Count)

newMenu.MenuItems.Add "E&xport Data File ...", "ExportToFile"
End If
End Sub


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to Compile a Macro Bobby Excel Programming 1 May 25th 09 12:46 PM
Compile error macro is 111K. how do I fix macro Dricon1 Excel Programming 2 February 18th 07 12:39 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
How to compile the macro dayanand108[_3_] Excel Programming 2 September 2nd 05 03:11 PM
macro compile error Jan Holmstrom Excel Programming 3 June 9th 05 01:46 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"