Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- Greetz, Just4fun |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You cannot generate a random name string, it just doesn't make sense as
their is not a name string series as there is a number series. If you were holding the names in a table somewhere, you could generate a random number and then use that as an index into the table to get a name. But why would you want to do this, surely it is highly unlikely that this document will exist? -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Just4fun" wrote in message ... 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 -- Greetz, Just4fun |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
bob,
I think OP is writing a procedure for SPAMMING. else why need random names like the one he's proposing? just4fun... nah! keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Bob Phillips" wrote: You cannot generate a random name string, it just doesn't make sense as their is not a name string series as there is a number series. If you were holding the names in a table somewhere, you could generate a random number and then use that as an index into the table to get a name. But why would you want to do this, surely it is highly unlikely that this document will exist? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think he meant the part after the three digits would not be always the
same - perhaps random was a poorly chosen descriptive term to indicate this. -- Regards, Tom Ogilvy "keepITcool" wrote in message ... bob, I think OP is writing a procedure for SPAMMING. else why need random names like the one he's proposing? just4fun... nah! keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Bob Phillips" wrote: You cannot generate a random name string, it just doesn't make sense as their is not a name string series as there is a number series. If you were holding the names in a table somewhere, you could generate a random number and then use that as an index into the table to get a name. But why would you want to do this, surely it is highly unlikely that this document will exist? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Tom Ogilvy" wrote in
: I think he meant the part after the three digits would not be always the same - perhaps random was a poorly chosen descriptive term to indicate this. And right as you are Tom ;)) (did I already tell ya i'm kinda of a newebee ?) -- Greetz, Just4fun |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
keepITcool wrote in
: bob, I think OP is writing a procedure for SPAMMING. else why need random names like the one he's proposing? just4fun... nah! keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Bob Phillips" wrote: You cannot generate a random name string, it just doesn't make sense as their is not a name string series as there is a number series. If you were holding the names in a table somewhere, you could generate a random number and then use that as an index into the table to get a name. But why would you want to do this, surely it is highly unlikely that this document will exist? Is what I am doing called "spamming" ? (posting the same question in 2 newsgroups) If so... sorry for that. (forgive me for my noobnes) Theo. -- |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() dim sStr as String, sStr1 as String sStr = Trim(Activecell.Text) sStr1 = Dir("c:\Myfiles\" & sStr & "_*.xls) if sStr1 < "" then workbooks.Open "C:\MyFiles\" & sStr1 End if I am not sure where you want to open a doc file, but you can't open it in Excel. I used .xls as the extension, but perhaps this is a word question and you are posting in the wrong group. -- Regards, Tom Ogilvy "Just4fun" wrote in message ... 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 -- Greetz, Just4fun |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Tom Ogilvy" wrote in
: Hi Tom, you'r wrong on the fact that it's not possible to open a ..doc file from within Escel.....it can be done. Thanks to Don and Juan I made it happen. I am not sure where you want to open a doc file, but you can't open it in Excel. I used .xls as the extension, but perhaps this is a word question and you are posting in the wrong group. -- Greetz, Just4fun |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If the doc file is a word document as is usually implied by the doc
extension, then it can not be opened in excel. Please demonstrate that this is incorrect. Where did Don and Juan demonstrate this magical capability. -- Regards, Tom Ogilvy "Just4fun" wrote in message ... "Tom Ogilvy" wrote in : Hi Tom, you'r wrong on the fact that it's not possible to open a .doc file from within Escel.....it can be done. Thanks to Don and Juan I made it happen. I am not sure where you want to open a doc file, but you can't open it in Excel. I used .xls as the extension, but perhaps this is a word question and you are posting in the wrong group. -- Greetz, Just4fun |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Based on the code you posted:
Dim wdapp As Object strFilename = "_document.doc" Set wdapp = CreateObject("Word.Application") With wdapp .Documents.Open Filename:="C:\my documents\" & ActiveCell.Value & strFilename .Visible = True End With Set wdapp = Nothing End Sub It is obvious that you are not opening the document in Excel. Using Excel to manipulate word to open the document does not open it in Excel as you have stated. Also, your code does not answer the current question you ask. So I wonder why you say Don and Juan have provided the answer. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... If the doc file is a word document as is usually implied by the doc extension, then it can not be opened in excel. Please demonstrate that this is incorrect. Where did Don and Juan demonstrate this magical capability. -- Regards, Tom Ogilvy "Just4fun" wrote in message ... "Tom Ogilvy" wrote in : Hi Tom, you'r wrong on the fact that it's not possible to open a .doc file from within Escel.....it can be done. Thanks to Don and Juan I made it happen. I am not sure where you want to open a doc file, but you can't open it in Excel. I used .xls as the extension, but perhaps this is a word question and you are posting in the wrong group. -- Greetz, Just4fun |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oke...
I will try to explain what: While working in Excel. A planner puts a value (f.i. 101) in cell B2 Where column B is "Customer requierment". And these Customer req. are saved as: 101_smith_retail.doc 102_Johnson_hardware.doc 103_Kelly_cycles.doc After that I select B2 and run my macro. (see the macro below) And this results in a word document (101_document.doc) to be opened. (correct Tom, ....not IN excel, but as a normal WORD document.) But: like the list (101, 102, 103...) shows, the last part of each document name differs. Maybe I use the wrong words to describe my exact wishes and so. (but being Dutch, I do my best) T.i.a. Theo. - - - - - - - - - - - - - - - - - - - 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
after opening existing spreadsheet can't input data anymore | Excel Worksheet Functions | |||
Opening a file with User Input | Excel Discussion (Misc queries) | |||
opening an excel file opens a duplicate file of the same file | Excel Discussion (Misc queries) | |||
Opening a template form & renaming it from a cell input automatica | Excel Discussion (Misc queries) | |||
Opening a text file for input | Excel Programming |