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
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