If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Juan, I wanted to open a .doc file (my mistake)
Hi All,
hope one of you can help me. I would like to open a file by pushing a button. Oke..I know how to. for instance: Workbooks.Open Filename:= _ "C:\My documents\dowcument.doc" But it's a little more difficult. say I ask for a 4 digits numeric input in a cell. as an example: 1300 is entered. Now, by (double)clicking the cell or selecting the cell and pressing a button. I would like to open this file: "C:\My documents\1300_document.doc" This was the example i received from Juan: MyFile = "C:\Documents and Settings\TG\Mijn Documenten\" & ActiveCell.Value & "_document.xls" Application.Workbooks.Open MyFile But this opens a .xls not a .doc What do I have to change to make it open a .doc file? Your help would do me a great favor. Thanks in advance, Theo. -- Greetz, Just4fun |
#3
|
|||
|
|||
Juan, I wanted to open a .doc file (my mistake)
I just noticed you wanted WORD. Try one of these ideas
Sub openxmas() Dim appWD As Object Dim wdDoc As Document Set appWD = CreateObject("Word.Application") appWD.Visible = True appWD.ChangeFileOpenDirectory ActiveWorkbook.Path appWD.Documents.Open Filename:="XmasListEnvelopes.doc" Set wdDoc = appWD.ActiveDocument End Sub Sub OpenDocument() 'NOT used Dim wdApp As Word.Application strFilename = "XmasListEnvelopes1.doc" Set wdApp = CreateObject("Word.Application") With wdApp .Documents.Open Filename:=ThisWorkbook.Path & "\" & strFilename .Visible = True End With Set wdApp = Nothing End Sub -- Don Guillett SalesAid Software "Just4fun" wrote in message ... Hi All, hope one of you can help me. I would like to open a file by pushing a button. Oke..I know how to. for instance: Workbooks.Open Filename:= _ "C:\My documents\dowcument.doc" But it's a little more difficult. say I ask for a 4 digits numeric input in a cell. as an example: 1300 is entered. Now, by (double)clicking the cell or selecting the cell and pressing a button. I would like to open this file: "C:\My documents\1300_document.doc" This was the example i received from Juan: MyFile = "C:\Documents and Settings\TG\Mijn Documenten\" & ActiveCell.Value & "_document.xls" Application.Workbooks.Open MyFile But this opens a .xls not a .doc What do I have to change to make it open a .doc file? Your help would do me a great favor. Thanks in advance, Theo. -- Greetz, Just4fun |
#4
|
|||
|
|||
Juan, I wanted to open a .doc file (my mistake)
Don
Sorry to step in, now I'm interested two... I've tried both exaples but an error ocurrs, it says: Compile Error User-Defined Type not Defined [ok] [Help] Any ideas.... Juan -----Original Message----- I just noticed you wanted WORD. Try one of these ideas Sub openxmas() Dim appWD As Object Dim wdDoc As Document Set appWD = CreateObject("Word.Application") appWD.Visible = True appWD.ChangeFileOpenDirectory ActiveWorkbook.Path appWD.Documents.Open Filename:="XmasListEnvelopes.doc" Set wdDoc = appWD.ActiveDocument End Sub Sub OpenDocument() 'NOT used Dim wdApp As Word.Application strFilename = "XmasListEnvelopes1.doc" Set wdApp = CreateObject("Word.Application") With wdApp .Documents.Open Filename:=ThisWorkbook.Path & "\" & strFilename .Visible = True End With Set wdApp = Nothing End Sub -- Don Guillett SalesAid Software "Just4fun" wrote in message ... Hi All, hope one of you can help me. I would like to open a file by pushing a button. Oke..I know how to. for instance: Workbooks.Open Filename:= _ "C:\My documents\dowcument.doc" But it's a little more difficult. say I ask for a 4 digits numeric input in a cell. as an example: 1300 is entered. Now, by (double)clicking the cell or selecting the cell and pressing a button. I would like to open this file: "C:\My documents\1300_document.doc" This was the example i received from Juan: MyFile = "C:\Documents and Settings\TG\Mijn Documenten\" & ActiveCell.Value & "_document.xls" Application.Workbooks.Open MyFile But this opens a .xls not a .doc What do I have to change to make it open a .doc file? Your help would do me a great favor. Thanks in advance, Theo. -- Greetz, Just4fun . |
#5
|
|||
|
|||
Juan, I wanted to open a .doc file (my mistake)
I just tryed changing the definition type for wdApp from word.application to object and it works great... Thanks Don Theo, I think you can figure it out from here don't you... Don's code works (the second one) changing dim wdapp as Word.Application to dim wdapp as object Cheers Juan -----Original Message----- Don Sorry to step in, now I'm interested two... I've tried both exaples but an error ocurrs, it says: Compile Error User-Defined Type not Defined [ok] [Help] Any ideas.... Juan -----Original Message----- I just noticed you wanted WORD. Try one of these ideas Sub openxmas() Dim appWD As Object Dim wdDoc As Document Set appWD = CreateObject("Word.Application") appWD.Visible = True appWD.ChangeFileOpenDirectory ActiveWorkbook.Path appWD.Documents.Open Filename:="XmasListEnvelopes.doc" Set wdDoc = appWD.ActiveDocument End Sub Sub OpenDocument() 'NOT used Dim wdApp As Word.Application strFilename = "XmasListEnvelopes1.doc" Set wdApp = CreateObject("Word.Application") With wdApp .Documents.Open Filename:=ThisWorkbook.Path & "\" & strFilename .Visible = True End With Set wdApp = Nothing End Sub -- Don Guillett SalesAid Software "Just4fun" wrote in message ... Hi All, hope one of you can help me. I would like to open a file by pushing a button. Oke..I know how to. for instance: Workbooks.Open Filename:= _ "C:\My documents\dowcument.doc" But it's a little more difficult. say I ask for a 4 digits numeric input in a cell. as an example: 1300 is entered. Now, by (double)clicking the cell or selecting the cell and pressing a button. I would like to open this file: "C:\My documents\1300_document.doc" This was the example i received from Juan: MyFile = "C:\Documents and Settings\TG\Mijn Documenten\" & ActiveCell.Value & "_document.xls" Application.Workbooks.Open MyFile But this opens a .xls not a .doc What do I have to change to make it open a .doc file? Your help would do me a great favor. Thanks in advance, Theo. -- Greetz, Just4fun . . |
#6
|
|||
|
|||
Juan, I wanted to open a .doc file (my mistake)
Don, Theo
Both codes work, just define dim appWD as object dim wdDoc as object in the fisrt one and dim wdApp as Object in the second one... and of course route to an existing file... Cheers Juan -----Original Message----- Don Sorry to step in, now I'm interested two... I've tried both exaples but an error ocurrs, it says: Compile Error User-Defined Type not Defined [ok] [Help] Any ideas.... Juan -----Original Message----- I just noticed you wanted WORD. Try one of these ideas Sub openxmas() Dim appWD As Object Dim wdDoc As Document Set appWD = CreateObject("Word.Application") appWD.Visible = True appWD.ChangeFileOpenDirectory ActiveWorkbook.Path appWD.Documents.Open Filename:="XmasListEnvelopes.doc" Set wdDoc = appWD.ActiveDocument End Sub Sub OpenDocument() 'NOT used Dim wdApp As Word.Application strFilename = "XmasListEnvelopes1.doc" Set wdApp = CreateObject("Word.Application") With wdApp .Documents.Open Filename:=ThisWorkbook.Path & "\" & strFilename .Visible = True End With Set wdApp = Nothing End Sub -- Don Guillett SalesAid Software "Just4fun" wrote in message ... Hi All, hope one of you can help me. I would like to open a file by pushing a button. Oke..I know how to. for instance: Workbooks.Open Filename:= _ "C:\My documents\dowcument.doc" But it's a little more difficult. say I ask for a 4 digits numeric input in a cell. as an example: 1300 is entered. Now, by (double)clicking the cell or selecting the cell and pressing a button. I would like to open this file: "C:\My documents\1300_document.doc" This was the example i received from Juan: MyFile = "C:\Documents and Settings\TG\Mijn Documenten\" & ActiveCell.Value & "_document.xls" Application.Workbooks.Open MyFile But this opens a .xls not a .doc What do I have to change to make it open a .doc file? Your help would do me a great favor. Thanks in advance, Theo. -- Greetz, Just4fun . . |
#7
|
|||
|
|||
Juan, I wanted to open a .doc file (my mistake)
"Juan Sanchez" wrote...
Sorry to step in, now I'm interested two... I've tried both exaples but an error ocurrs, it says: Compile Error User-Defined Type not Defined [ok] [Help] Any ideas.... -----Original Message----- I just noticed you wanted WORD. Try one of these ideas Sub openxmas() Dim appWD As Object Dim wdDoc As Document .... It's 'Document'. In *Excel* VBA, ain't no Document class. In Excel VBA projects, you need to declare wdDoc as Object. |
#8
|
|||
|
|||
Didn't know it was this easy to make friends :)))
Guys....
you realy made a guy happy. Don...Thanks a lot. Juan..thanks again. I had to work the macro a little, bit now it works !!! (and being the noob I am, that was more luck than skills 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 But it works....!!! When nearby drop in for a beer or Lemonade. Greets,Theo. (Holland, Helmond) -- Greetz, Just4fun |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Productkey problem when installing office 2003 on network | Stefan Schreurs | Setup, Installing & Configuration | 1 | June 1st, 2004 11:16 PM |
GPO Office 2003 | Tony | Setup, Installing & Configuration | 1 | May 12th, 2004 10:42 AM |
Excel 2000 tries to open unrecognizable file on startup | 1 Just Jeff | Setting up and Configuration | 2 | November 24th, 2003 01:41 AM |
cannot open excel file with 97 | Bob | Setting up and Configuration | 1 | November 12th, 2003 02:43 AM |
excel; File Open or click on open folder | [email protected] | Setting up and Configuration | 0 | October 29th, 2003 05:15 PM |