runtime error 104

Redhawk

New Member
Joined
Aug 12, 2005
Messages
24
Good day everyone.
I have written a macro, and linked it to a control, to open an existing workbook and then to insert text in a specific cell(group of cells, the cells are merged). Regardless of what i change i keep on getting a runtime error 1004.

Here is the code i used:

Private Sub CommandButton1_Click()

' INSERTWHSQINWO Macro
' This macro inserts the white melamine squareline finish in the works order

Workbooks.Open Filename:="E:\Leisure Kitchens\NCS\PM.xls", UpdateLinks _
:=3
Range("F4:J6").Select
ActiveCell.FormulaR1C1 = "WHITE MELAMINE SQUARELINE"
With ActiveCell.Characters(Start:=1, Length:=25).Font
.Name = "Tahoma"
.FontStyle = "Regular"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

End Sub

Any suggestions would be greatly appreciated.

Thanks
Red
 
My thanks to all.

It finally works. Herewith for your interest the final code:

Private Sub CommandButton1_Click()


ChDir "E:\Leisure Kitchens\NCS"
Workbooks.Open Filename:="E:\Leisure Kitchens\NCS\PM.xls", UpdateLinks:=3
With ActiveWorkbook.ActiveSheet.Range("F4:J6")
.Value = "WHITE MELAMINE SQUARELINE"
With ActiveCell.Characters(Start:=1, Length:=25).Font
.Name = "Tahoma"
.FontStyle = "Regular"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
End With

End Sub


Once again, many thanks

Red
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Red

Glad to help.:)

By the way you don't actually need the ChDir, as you are using the full path when opening the workbook.
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,073
Members
449,205
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top