Consulting

Results 1 to 6 of 6

Thread: opening a word document

  1. #1

    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

    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

  2. #2
    this vba doesnt work.
    what does happen?
    do you get error or no result? does your code freeze?

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    It opens but it is hidden.

  4. #4
    it doest appear to do anything,no eroor msg or freezing.

  5. #5
    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?

  6. #6
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •