Open word doc from user form button

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,699
Office Version
  1. 2007
Platform
  1. Windows
Hi all,
I have a user form which has various text boxes containing info.
One text box relates to a word doc receipt as just a basic number system.
Is there a code we can use to apply to a button on the user form that would then look at a specific text box and open its relevant word doc receipt.

The text box which contains the receipt number on the user form is txtInvoiceNumber

The path to the word doc is C drive,REMOTES ETC,DR COPY INVOICES,Invoice 107.doc

Obviously this receipt is 107 but as time goes on more will be added 108,109,110 etc etc

Any advice would be great thanks.

I havent applied a button yet as awaiting code info.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
I have applied the following code to a now inserted command button on the user form.

Code:
Private Sub CommandButton1_Click()Set wordApp = CreateObject("word.application")
wordApp.Documents.Open ThisWorkbook.Path & "/" & TextBox14.Value & ".doc"
wordApp.Visable = True
End Sub

Please can you advise how i correctly add the path, C drive,REMOTES ETC,DR COPY INVOICES,Invoice 107.doc
 
Upvote 0
Just an update and now stuck.
The following it what ive done so far but after pressing the command button there is a long pause before i see a message.

Microsoft excel is waiting for another application to complete an OLE action

Code in use at present which needs a little more for it to work.
Code:
Private Sub CommandButton1_Click()Set wordApp = CreateObject("word.application")
wordApp.Documents.Open "C:\Users\Ian\Desktop\REMOTES ETC\DR COPY INVOICES" & "/" & txtInvoiceNumber.Value & ".doc"


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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