Macro Error... Word 2003

J

jfcby

Hello,

I've created a user form with a button to run a macro but when I click
the button I,m getting this compile error: Expected function or
Variable. What is causing this error?

Userform code:
Private Sub CommandButton2_Click()
Application.Run Project.Module1.ChangeFontTypeSize
End Sub

Modules Code:
Sub ChangeFontTypeSize()
' Change Font Type & Size
Selection.Font.Name = "MS Sans Serif"
Selection.Font.Size = 20
End Sub

Thank you for your help,
jfcby
 
M

macropod

Hi jfcby,

Try:

Private Sub CommandButton2_Click()
Call ChangeFontTypeSize
End Sub

Sub ChangeFontTypeSize()
' Change Font Type & Size
With Selection.Font
.Name = "MS Sans Serif"
.Size = 20
End With
End Sub
 
J

jfcby

Hi jfcby,

Try:

Private Sub CommandButton2_Click()
Call ChangeFontTypeSize
End Sub

Sub ChangeFontTypeSize()
' Change Font Type & Size
With Selection.Font
  .Name = "MS Sans Serif"
  .Size = 20
End With
End Sub

--
Cheers
macropod
[MVP - Microsoft Word]



jfcby said:
I've created a user form with a button to run a macro but when I click
the button I,m getting this compile error: Expected function or
Variable. What is causing this error?
Userform code:
 Private Sub CommandButton2_Click()
   Application.Run Project.Module1.ChangeFontTypeSize
End Sub
Modules Code:
 Sub ChangeFontTypeSize()
 ' Change Font Type & Size
   Selection.Font.Name = "MS Sans Serif"
   Selection.Font.Size = 20
End Sub
Thank you for your help,
jfcby- Hide quoted text -

- Show quoted tex

Hello macropod,

Your modified code worked great!

Thank you for your help,
jfcby
 

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