|
-
Apr 6th, 2005, 05:33 AM
#1
Thread Starter
Lively Member
Open Word doc through app.path?
hello all-
I have the following code to open a word template in the app.path directory....
VB Code:
Dim appWord As Object
Dim strDoc As String
strDoc = " & app.path & Labels1.dot"
Set appWord = CreateObject("Word.Application")
appWord.Documents.Open strDoc
appWord.Visible = True
I get an error message that it cant find the document????
did I code this correctly? Thanks for all your help in advanced!!!
-
Apr 6th, 2005, 07:40 AM
#2
Addicted Member
Re: Open Word doc through app.path?
VB Code:
Dim appWord As Object
Dim strDoc As String
strDoc = " & app.path & Labels1.dot"
Set appWord = CreateObject("Word.Application")
appWord.Documents.Open strDoc
appWord.Visible = True
your strDoc should be:
VB Code:
strDoc = app.path & "Labels1.dot"
also, you arent showing what is happening with app.path. so it could be this as well
HTH
if you fail to plan, you plan to fail
-
Apr 6th, 2005, 03:46 PM
#3
Thread Starter
Lively Member
-
Apr 6th, 2005, 04:10 PM
#4
Re: Open Word doc through app.path?
Just wanted to point out that if your dot is in the root directory then you will end up with
double backslashes - C:\\Labels.dot.
VB Code:
If Len(App.Path) = 3 Then
'In root dir
strDoc = App.Path & "Labels1.dot"
Else
'Not in root
strDoc = App.Path & "\Labels.dot")
End If
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 6th, 2005, 04:28 PM
#5
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|