A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Juan, I wanted to open a .doc file (my mistake)



 
 
Thread Tools Display Modes
  #1  
Old June 24th, 2004, 11:28 PM
Just4fun
external usenet poster
 
Posts: n/a
Default 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
  #2  
Old June 24th, 2004, 11:39 PM
Don Guillett
external usenet poster
 
Posts: n/a
Default Juan, I wanted to open a .doc file (my mistake)

Right click sheet tabview codeinsert this.Type in name of file to goto in
a cell and double click on the cell. If open, file will be activated. If
not, it will be opened. Modify to suit.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Application.DisplayAlerts = False
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
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



  #3  
Old June 24th, 2004, 11:42 PM
Don Guillett
external usenet poster
 
Posts: n/a
Default 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  
Old June 25th, 2004, 12:15 AM
Juan Sanchez
external usenet poster
 
Posts: n/a
Default 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  
Old June 25th, 2004, 12:24 AM
Juan Sanchez
external usenet poster
 
Posts: n/a
Default 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  
Old June 25th, 2004, 12:29 AM
Juan Sanchez
external usenet poster
 
Posts: n/a
Default 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  
Old June 25th, 2004, 12:34 AM
Harlan Grove
external usenet poster
 
Posts: n/a
Default 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  
Old June 25th, 2004, 08:10 PM
Just4fun
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 02:15 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.