Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OLE Object button coding

Status
Not open for further replies.

Flammer

Technical User
Jan 30, 2001
10
GB
I have documents being stored in an OLE Object on a database and I want to do it so that when you click on a button that document will load.

So far I have got......

Private Sub Command50_Click()
On Error GoTo Err_Command50_Click
' Button launches Word and opens a specified document
' And runs an optional macro. the macro could print out the word doc and quit

Dim retval As Variant
Dim DocName, MacroName As String
' Drive and Full path to name and location of Word document
DocName = "F:\Somefolder\MyDoc.doc"

'Note full path to Word including Drive and folder
retval = Shell("c:\Program Files\Office\WinWord.exe" & " " & DocName & MacroName, vbNormalFocus)

Exit_Command50_Click:
Exit Sub

Err_Command50_Click:
MsgBox Err.Description
Resume Exit_Command50_Click

End Sub



But I need to change the coding of....


DocName = "F:\Somefolder\MyDoc.doc"


So that it will always open the document that is in the OLE Source at that time.

Can anyone help?
 
Have you tried adding quotes as part of the string itself?

dim sFormName as string

sFormName = "MyDocument"

'Add the quotes.
sFormName = chr$(34) & sFormName & chr$(34)

You don't need two steps, I was just showing what I meant.
I have done this in the past to other controls and it worked for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top