-
opening a word document
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
Code:
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
-
Quote:
this vba doesnt work.
what does happen?
do you get error or no result? does your code freeze?
-
It opens but it is hidden.
-
it doest appear to do anything,no eroor msg or freezing.
-
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?
-
Code:
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