PDA

View Full Version : opening a word document



ashgull80
07-23-2014, 02:16 PM
hi
i would just like some help on why this vba doesnt work.
im trying to make it open an existing work doc then copy the data into the word doc.
it works find if the "invoice template" is already open but it wont open it if its not.
Thank you


Private Sub cmdEnter_Click()
With GetObject("C:\Users\home\Documents\AT Electrical\Invoices\InvoiceTemplate.docx")

.tables(1).Cell(1, 2).Range.Text = frmwriteinvoice.txtinvoicenumber.Value
.tables(1).Cell(3, 2).Range.Text = frmwriteinvoice.txtinvoicedate.Value
.tables(1).Cell(5, 2).Range.Text = frmwriteinvoice.cboinvoicejobnumber.Value

End With


End Sub

westconn1
07-24-2014, 03:20 AM
this vba doesnt work.what does happen?
do you get error or no result? does your code freeze?

snb
07-24-2014, 04:01 AM
It opens but it is hidden.

ashgull80
07-24-2014, 06:29 AM
it doest appear to do anything,no eroor msg or freezing.

westconn1
07-24-2014, 02:22 PM
did you test if it is working, but not visible, as suggested above?
did you test to save, then see if the document is updated?

snb
07-25-2014, 01:15 AM
Private Sub cmdEnter_Click()
With GetObject("C:\Users\home\Documents\AT Electrical\Invoices\InvoiceTemplate.docx")
.tables(1).Cell(1, 2).Range.Text = txtinvoicenumber.Text
.tables(1).Cell(3, 2).Range.Text = txtinvoicedate.Text
.tables(1).Cell(5, 2).Range.Text = cboinvoicejobnumber.Value
.windows(1).visible=true
End With
End Sub