Word document?

Daniellawson

Board Regular
Joined
Oct 9, 2002
Messages
61
Is it possible to get a word Document to open on the click of a button with certain values from my database?

e.g...

Name
Number

GRADE


(And then maybe it auto prints of this information?) - not essential..


thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
You can control Word from Excel (Or Access, since you didn't mention where's your database) with VBA, but, it's not clear what you want (You say that you want to open a document, but then you also say that you want certain values in it, so, is it a new document ?)
 
Upvote 0
Hi

I have made this script so range A1 to A20 is paste over to word does this help, i suggest edit teh range to your requirements

Jack

Place this code in normal standard module and link to command button

Sub Excel_to_Word_JackintheUK()

Range("A1:A20").Select
Selection.Copy

Set Word6 = CreateObject("Word.Basic")
With Word6
If UCase(Left(Application.OperatingSystem, 3)) <> "MAC" Then
.AppRestore
.AppMaximize 1
Else
AppActivate "Microsoft Word"
End If
.FileNewDefault
'.InsertPara
.Insert "JACK - Test from Excel"
.startofline 15
' .Bold
' .CenterPara
'.startofline 15
Selection.PasteSpecial Paste:=xlValues, operation:=xlNone, _
skipblanks:=False, Transpose:=False
Application.CutCopyMode = False

End With


' MARKER Excel to WORD
End Sub
 
Upvote 0
I typed that in my button code.. (For a test)

Private Sub SendLetter_Click()
Sub Excel_to_Word_JackintheUK()

Range("A1:A20").Select
Selection.Copy

Set Word6 = CreateObject("Word.Basic")
With Word6
If UCase(Left(Application.OperatingSystem, 3)) <> "MAC" Then
.AppRestore
.AppMaximize 1
Else
AppActivate "Microsoft Word"
End If
.FileNewDefault
'.InsertPara
.Insert "JACK - Test from Excel"
.startofline 15
' .Bold
' .CenterPara
'.startofline 15
Selection.PasteSpecial Paste:=xlValues, operation:=xlNone, _
skipblanks:=False, Transpose:=False
Application.CutCopyMode = False

End With


' MARKER Excel to WORD
End Sub

End Sub


But i get the error :

COMPILE ERROR - EXPECTED END SUB

then a yellow arroe pointing to Private Sub SendLetter_Click()..

Probably something simple but im a newbie :smile:

thnx
 
Upvote 0
OK you have not done as i have instructed the private sub DELETE it

put this in and link command button - perfect for me..

Sub Excel_to_Word_JackintheUK()

Range("A1:A20").Select
Selection.Copy
Sub Word()
Set Word6 = CreateObject("Word.Basic")
With Word6
If UCase(Left(Application.OperatingSystem, 3)) <> "MAC" Then
.AppRestore
.AppMaximize 1
Else
AppActivate "Microsoft Word"
End If
.FileNewDefault
'.InsertPara
.Insert "JACK - Test from Excel"
.startofline 15
' .Bold
' .CenterPara
'.startofline 15
'Selection.PasteSpecial Paste:=xlValues, operation:=xlNone,
'skipblanks:=False, Transpose:=False
Application.CutCopyMode = False

End With
 
Upvote 0

Forum statistics

Threads
1,222,227
Messages
6,164,717
Members
451,912
Latest member
HMF009

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