473,473 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Elp in opening file in vb.

7 New Member
i want to open a word doc in vb. i have opened it by giving the file name directly,but i want the file name to be given as per the selected name in a listbox and typed character in a textbox. i have typed the following code,

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim objWord As Word.Application
  3. Set objWord = New Word.Application
  4. objWord.Visible = True
  5. objWord.Documents.Open App.Path & "List1.text" & "Text1.txt.docx"
  6. End Sub
but it is not working as the valuers are not coming please help!!
Feb 20 '12 #1
5 1440
Guido Geurs
767 Recognized Expert Contributor
App.Path & "List1.text" & "Text1.txt.docx"
You must respect the commandline syntax to open a file.
Like:
If the Doc is in the path=

"C:\myprogram\Folder1\mydocument.docx"

if List1.text = "Folder1" and Text1.txt = "mydocument" then the code is=

Expand|Select|Wrap|Line Numbers
  1. objWord.Documents.Open App.Path & "\" & List1.text & "\" & Text1.txt & ".docx"
Feb 20 '12 #2
Aravind Renjan
7 New Member
Thank you for your reply!
But still the file is not opening. The value selected in list is not coming.that is 'folder1' is not coming in the path to be opened.
please reply as soon as possible.
Feb 21 '12 #3
Guido Geurs
767 Recognized Expert Contributor
Can you give an example of the contents of the list and the other items?
Be cautious by the use of "App.Path" !!
Is the file to open in the folder or sub folder of the .VBP and other files ?
During the TEST RUN of the project the "App.path" is the folder where the .VBP and other files of the project are !!
During the run of the compiled .EXE it's the folder where the PROGRAM is !!
So the .DOC must always be in the folder (or sub folders) of the PROJECT or PROGRAM !!!
Feb 21 '12 #4
Aravind Renjan
7 New Member
Ok. But the file opens if I put it out of the folder. But when in the folder then a box comes"F:/mydocument.docx"not found. So it is that the selected item name of list box is not coming in the path specified.
Please reply fast!
Feb 21 '12 #5
Guido Geurs
767 Recognized Expert Contributor
Do you know how to use "Break point" and "Add Watch" ?
Feb 22 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Eric Caron | last post by:
Hi Here's my problem, I create a windows service with Config.xml file. All setup for my service is in this file. I create a windows application to manage these settings (Config.XML File). This...
2
by: Fraser Ross | last post by:
I want to prevent std::basic_ifstream from opening a file for reading when it is passed the file name with any wrong case of a letter. If that can't be done is there anything else that could be...
9
by: ben | last post by:
Hello, This really drives me nuts. Im opening an input file, and Im testing if it was open successfully. Thats it! I know that the file that Im trying to open DOES NOT exist but Im getting NO...
1
by: Alfons | last post by:
Hello, I have build a program that can do file transferring between a Windows XP computer and a DOS computer via a serial port. The Windows program I have build in C++ with Visual Studio 6.0....
28
by: Madhur | last post by:
Hello what about this nice way to open a file in single line rather than using if and else. #include<stdio.h> void main() { FILE *nd; clrscr();...
4
by: Pieter | last post by:
Hi, From my VB.NET 2005 application I need to be able to open Files an Directory's with their default application: - A word-doc must open in word - A excell-document in Excel etc - in case...
5
by: bimeldip | last post by:
Hi, I an tryin to create a html page where users can choose a file and open it however, i keep getting it wrong.So far this is wat i've worked on: (open.html) <html> <head> <title>Opening...
0
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I need to open a text file with .net remoting. This text file resides on another server. My server program running on the server has this method that opens the text file...
2
by: sam | last post by:
Sir, I just wanted to know how i will opened file (any exe or other type file )in c++ and run it. and how we will give path when we are opening it. please give me the code of this small...
2
by: PaulSW | last post by:
I have a macro that loops through and opens a number of files. In each file there is an event procedure upon opening that displays an informational msgbox (The only option is to click ok). I'm...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.