Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Assign Macro to Command Botton

If you are using Excel 97 then you must change the takefocusonclick property to
false off the Control toolbox button.

It is a bug in 97

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Nathaniel" wrote in message ...
I have assigned my macro to a command button it fails to
run. It gives run time error 1004. When I run the macro
alone using ALT F8 run macro it runs without giving any
errors.

Below is the sample macro and position where error occurs


Public f_name as variant

Public wkbBook as variant

Sub CommandButton1_Click()

f_name = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If f_name < False Then
MsgBox "Opening Raw Data Text File " & f_name
End If

'Opening Raw Data File

Workbooks.OpenText Filename:=f_name, Origin:= _
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
2), Array(17, 2), Array(30, 2), Array(39, 2))

Set wkbBook = ActiveWorkbook

Nortel wkbBook

End Sub


Sub Nortel(ByRef wkbBook As Workbook)

wkbBook.Activate


'To search for requires information

il = 1
Do While Cells(il, 1) < "CLASS: MONDAY" 'Run time
error occurs here
il = il + 1
Loop


End sub




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
Command botton Lou825 Excel Discussion (Misc queries) 3 April 13th 10 11:19 PM
I can't find the Assign Macro command Dave Excel Discussion (Misc queries) 3 September 27th 06 07:08 PM
Assign a macro to a command button SheriTingle Excel Discussion (Misc queries) 4 September 25th 06 06:38 PM
Command botton text font nsv Excel Discussion (Misc queries) 1 April 27th 06 09:43 AM
Assign Macro to Command Button Shunt Excel Programming 1 August 7th 03 02:07 PM


All times are GMT +1. The time now is 04:12 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"