PDA

View Full Version : Take textbox input and print off document



francozola25
08-13-2008, 08:59 AM
Hello i was wondering if someone could help me.

I have a userform with textbox called code.

What i want is for my user to input a code into the textbox and then open a document from the following:

Documents.Open(\\myserver\Documents\Codes\ (file://\\myserver\Documents\Codes\) & Code & ".Doc"

I want to have Code as a variable that will change everytime from the input into the textbox

The document that is opened is then sent to the printer

CreganTur
08-13-2008, 01:25 PM
If you are opening documents that already exist, would it not be better to use a combo box- that way you can predefine all of the 'codes' that the user can select. If you don't do this, then you will need some way to evaluate if a 'code' represents the name of an exisitng doc so that it can reject 'codes' that are not valid.

Are you wanting the document to be printed without opening it, or are you wanting the document to be opened so changes can be made and then printed, or do you want it to open and print?

francozola25
08-13-2008, 03:54 PM
hey thanks for your reply

a drop down would be great containing the filenames in the folder but would this be easy to do.

I just want to print the document, not make any changes.

francozola25
08-19-2008, 05:16 AM
Apologies i should of been clear at the start.

how would populate you populate the variable size array?

francozola25
08-19-2008, 05:29 AM
What i have is the following


Private Sub UserForm_Initialize()
'Files in folder listed in Listbox1
Dim FSO As Object, fld As Object, Fil As Object
Dim SubFolderName As String
Dim i As Integer
Set FSO = CreateObject("Scripting.FileSystemObject")
Me.ComboBox1.Clear 'clear previous entries
SubFolderName = "T:\"
Set fld = FSO.GetFolder(SubFolderName)
For Each Fil In fld.Files
i = i + 1
Me.ComboBox1.AddItem Fil.Name

Next Fil

End Sub



I just need to implement the bit that only .pdf files to be considered.