ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel to Word report problem (https://www.excelbanter.com/excel-programming/430955-excel-word-report-problem.html)

rharrison

Excel to Word report problem
 

I want to be able to open up a word document when a User Form opens in Excel.

Once the word document is open, I want to add information to it, depending
on criteria met whilst the user is using the form.

So far I have been able to the Word report to open, but I'm not able to add
further details to it when buttons are clicked in the user form. I'm sure
this is straightforward, but I am struggling to see where I would be going
wrong. Can anyone help?

Thanks.


Barb Reinhardt

Excel to Word report problem
 

Please post the code you have so far.

"rharrison" wrote:

I want to be able to open up a word document when a User Form opens in Excel.

Once the word document is open, I want to add information to it, depending
on criteria met whilst the user is using the form.

So far I have been able to the Word report to open, but I'm not able to add
further details to it when buttons are clicked in the user form. I'm sure
this is straightforward, but I am struggling to see where I would be going
wrong. Can anyone help?

Thanks.


rharrison

Excel to Word report problem
 
When the page loads, I have...

Set wordApp = CreateObject("Word.Application")

With wordApp
.Visible = True
.Activate
End With

Set doc = wordApp.Documents.Add

Then, when the individual clicks the button it has...

With wordApp.Selection

..typetext "Test"

etc.

End With

Obviously, it's not picking up the wordApp tag. But I'm not sure how to
reference the application I've opened. Any help would be greatly appreciated.

Many thanks.

"Barb Reinhardt" wrote:

Please post the code you have so far.

"rharrison" wrote:

I want to be able to open up a word document when a User Form opens in Excel.

Once the word document is open, I want to add information to it, depending
on criteria met whilst the user is using the form.

So far I have been able to the Word report to open, but I'm not able to add
further details to it when buttons are clicked in the user form. I'm sure
this is straightforward, but I am struggling to see where I would be going
wrong. Can anyone help?

Thanks.


Patrick Molloy

Excel to Word report problem
 
I'm not sure if this example is what you need, but I have a command button
on the form, btnWrite, which has the following code:

Option Explicit
Private Sub btnWrite_Click()
Dim wordApp As Object
Dim doc As Object

With CreateObject("Word.Application")
.Visible = True
.Activate
Set doc = .Documents.Add
.Selection.typetext txtName.Text & vbCrLf
.Selection.typetext txtAddress1.Text & vbCrLf
.Selection.typetext txtAddress2.Text
End With
Unload Me
End Sub

this writes the contents of three text boxes to the document


"rharrison" wrote in message
...
When the page loads, I have...

Set wordApp = CreateObject("Word.Application")

With wordApp
.Visible = True
.Activate
End With

Set doc = wordApp.Documents.Add

Then, when the individual clicks the button it has...

With wordApp.Selection

.typetext "Test"

etc.

End With

Obviously, it's not picking up the wordApp tag. But I'm not sure how to
reference the application I've opened. Any help would be greatly
appreciated.

Many thanks.

"Barb Reinhardt" wrote:

Please post the code you have so far.

"rharrison" wrote:

I want to be able to open up a word document when a User Form opens in
Excel.

Once the word document is open, I want to add information to it,
depending
on criteria met whilst the user is using the form.

So far I have been able to the Word report to open, but I'm not able to
add
further details to it when buttons are clicked in the user form. I'm
sure
this is straightforward, but I am struggling to see where I would be
going
wrong. Can anyone help?

Thanks.



All times are GMT +1. The time now is 02:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com