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
|
|||
|
|||
Getting from Access to Word
In a form, I have a listbox based on a table that contains Section,
Subsection, Page and Pathway. What I want to have happen is that selecting one of the lines in the listbox automatically activates the Pathway so that the specified document comes up in WORD. I’m just unable to do this, despite hours of frustration with macros, coding, etc. Can anyone help? |
#2
|
|||
|
|||
Getting from Access to Word
"Susan H. White" wrote in message
... In a form, I have a listbox based on a table that contains Section, Subsection, Page and Pathway. What I want to have happen is that selecting one of the lines in the listbox automatically activates the Pathway so that the specified document comes up in WORD. I'm just unable to do this, despite hours of frustration with macros, coding, etc. Can anyone help? What code are you using now? I would expect something like... Application.FollowHyperLink Me.ListBoxName.Column(3) -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#3
|
|||
|
|||
Getting from Access to Word
Exactly. I tried that code, built on a command button, just as you specified
earlier, but that didn't work. Then I tried building a macro. More failure. Can't believe I'm this stupid. Susan "Rick Brandt" wrote: "Susan H. White" wrote in message ... In a form, I have a listbox based on a table that contains Section, Subsection, Page and Pathway. What I want to have happen is that selecting one of the lines in the listbox automatically activates the Pathway so that the specified document comes up in WORD. I'm just unable to do this, despite hours of frustration with macros, coding, etc. Can anyone help? What code are you using now? I would expect something like... Application.FollowHyperLink Me.ListBoxName.Column(3) -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#4
|
|||
|
|||
Getting from Access to Word
"Susan H. White" wrote in message
... Exactly. I tried that code, built on a command button, just as you specified earlier, but that didn't work. Then I tried building a macro. More failure. Can't believe I'm this stupid. Susan Forget Macros. They will only hold you back. What exactly "didn't work"? Did you get an error? -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#5
|
|||
|
|||
Getting from Access to Word
I get Compile Error. Method or data member not found.
"Rick Brandt" wrote: "Susan H. White" wrote in message ... Exactly. I tried that code, built on a command button, just as you specified earlier, but that didn't work. Then I tried building a macro. More failure. Can't believe I'm this stupid. Susan Forget Macros. They will only hold you back. What exactly "didn't work"? Did you get an error? -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#6
|
|||
|
|||
Getting from Access to Word
"Susan H. White" wrote in message
... I get Compile Error. Method or data member not found. Does your Path contain spaces? If so you might need to wrap the whole value in an extra set of double-quotes. Application.FollowHyperLink Chr(34) & Me.ListBoxName.Column(3) & Chr(34) -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#7
|
|||
|
|||
Getting from Access to Word
OK I'll try that Rick. But before I go off on another trip to frustration,
can you tell me what "Chr(34)" is? We've not talked about that one before and I don't want to complicate the situation unless you say I need to. Thanks again, Susan "Rick Brandt" wrote: "Susan H. White" wrote in message ... I get Compile Error. Method or data member not found. Does your Path contain spaces? If so you might need to wrap the whole value in an extra set of double-quotes. Application.FollowHyperLink Chr(34) & Me.ListBoxName.Column(3) & Chr(34) -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#8
|
|||
|
|||
Getting from Access to Word
"Susan H. White" wrote in message
... OK I'll try that Rick. But before I go off on another trip to frustration, can you tell me what "Chr(34)" is? We've not talked about that one before and I don't want to complicate the situation unless you say I need to. Thanks again, Susan Chr(34) is the double-quote character. Using the Chr() function eliminates the need to put double-quotes around your double-quotes (which can get confusing). Do you have at least one path that contains no spaces that you can test with, even if that means creating a temporary one? That should tell you if that is the problem with what you have now. -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#9
|
|||
|
|||
Getting from Access to Word
found this:
Question From my Microsoft Access form I would like to hyperlink to a Microsoft Word document. At present each record contains a document name and a full file path to where the document is stored. I would like to open Word and view the specified document. Answer The details below show how to Open the Microsoft Word application and view the document specified in the associated record on the form. Paste the following code into a module: '------------------Code Start----------------------- Sub OpenWordDoc(strDocName As String) Dim objApp As Object 'Opens the document Set objApp = CreateObject("Word.Application") objApp.Visible = True objApp.Documents.Open strDocName End Sub '------------------Code End------------------------- Then from the On Click event of the command button on the form (named cmdOpenWordDoc in this example) paste the following (where Me.FilePath is the name of the control on the form storing the path to the associated file): '------------------Code Start----------------------- Private Sub cmdOpenWordDoc_Click() 'Check to see that there is a document file path associated with the record If IsNull(Me.FilePath) Or Me.FilePath = "" Then MsgBox "Please Ensure There Is A File Path Associated For This Document", _ vbInformation, "Action Cancelled" Exit Sub Else 'Check that the document specified in the file path is actually there If (Dir(Me.FilePath) = "") Then MsgBox "Document Does Not Exist In The Specified Location", _ vbExclamation, "Action Cancelled" Exit Sub Else 'Opens document in Word Call OpenWordDoc(Me.FilePath) End If End If End Sub '------------------Code End----------------------- This will initially check to see that the Microsoft Access record contains a File Path in the control labelled FilePath. If there is no entry in this field a message box is displayed to inform the user and the action is cancelled. Error when there is no file path associated with the record If there is a file path entered, the next section If (Dir(Me.FilePath) = "") checks to see that the document is present in the specified location. If there is no document present the action is again cancelled and a message box informs the user. Error when the document does not exist in the specifed location You can now open up Microsoft Word documents stored in any location as long as you specify the full path to the file. My guess would be you don't have the reference set. Lewie Rick Brandt wrote: "Susan H. White" wrote in message ... OK I'll try that Rick. But before I go off on another trip to frustration, can you tell me what "Chr(34)" is? We've not talked about that one before and I don't want to complicate the situation unless you say I need to. Thanks again, Susan Chr(34) is the double-quote character. Using the Chr() function eliminates the need to put double-quotes around your double-quotes (which can get confusing). Do you have at least one path that contains no spaces that you can test with, even if that means creating a temporary one? That should tell you if that is the problem with what you have now. -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#10
|
|||
|
|||
Getting from Access to Word
Rick: Following your suggestion, we seem to be getting closer. Now I get "Run
Time Error 432. File name or class name not found during Automation operation." I'll give it a rest for a bit and then go on to try Lewie's solution. Thanks again. Susan "Rick Brandt" wrote: "Susan H. White" wrote in message ... OK I'll try that Rick. But before I go off on another trip to frustration, can you tell me what "Chr(34)" is? We've not talked about that one before and I don't want to complicate the situation unless you say I need to. Thanks again, Susan Chr(34) is the double-quote character. Using the Chr() function eliminates the need to put double-quotes around your double-quotes (which can get confusing). Do you have at least one path that contains no spaces that you can test with, even if that means creating a temporary one? That should tell you if that is the problem with what you have now. -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
Thread Tools | |
Display Modes | |
|
|