Need help on opening file through input once more !

  • Thread starter Thread starter Just4fun
  • Start date Start date
J

Just4fun

Hi all,

with some help (!) I managed to have a .doc file to open after
running a macro with a given input in a cell.

For instance:

cell b2 hs the value 101

Now after selecting the cell (B2) and running the macro.
The file 101_document will be opened.


However: the "_document" part is a random name.
My list of files looks a bit like this:

101_smith_retail
102_Johnson_hardware
103_Kelly_cycles

How can I open a file after input?

So the line: strFilename = "_document.doc"
should be more like: strFilename = random_name ????




Sub test()
'Dim MyFile As String

Dim wdapp As Object
strFilename = "_document.doc"
Set wdapp = CreateObject("Word.Application")
With wdapp
.Documents.Open Filename:="C:\" & ActiveCell.Value & strFilename
.Visible = True
End With
Set wdapp = Nothing
End Sub



I hope my description is clear enough for you to understand what i'm
looking for?


Thanks in advance for your help, Theo
 
See response in .programming, and keep to a single post, even if to many
groups.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Oke,

Thanks Bob.

And excuses from my side.

But i'm rather new in these (very welcome) newsgroups.

Theo.
 
Back
Top