Results 1 to 4 of 4
  1. #1
    naseerrahaman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Location
    India
    Posts
    12

    Need VBA code to browse folder and open inside text file with word document automatic

    Hi Team,



    Could any one of you please help me to get the vba code which take me to browse folder and open text file with word document automatically.

    Just i want to select folder and the vba code should open inside folders text file with word document.

    Thanks in advance for the help.

    Thanks and Regards,
    Naseer ur Rahaman.
    E mail : naseerrahaman@gmail.com

  2. #2
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    found this on a forum..
    Dim fd As FileDialog
    Dim objfl As Variant
    Dim filnam As String

    ... other code .....

    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    With fd
    .ButtonName = "Select"
    .AllowMultiSelect = False
    .Filters.Add "Text Files", "*.txt;*.csv;*.tab;*.asc", 1
    .title = "Choose Transactions file to import"
    .InitialView = msoFileDialogViewDetails
    .Show
    For Each objfl In .SelectedItems
    filnam = objfl
    Next objfl
    On Error GoTo 0
    End With

    Set fd = Nothing

    ''' filnam then used in following code . Note that although .AllowMultiSelect is set to False, you still need to run through the For each loop.

    Hope this helps

    change the .filters to add doc.. for word documents

  3. #3
    naseerrahaman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Location
    India
    Posts
    12

    Need VBA code to browse folder and open inside text file with word document automati

    Quote Originally Posted by alcapps View Post
    found this on a forum..
    Dim fd As FileDialog
    Dim objfl As Variant
    Dim filnam As String

    ... other code .....

    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    With fd
    .ButtonName = "Select"
    .AllowMultiSelect = False
    .Filters.Add "Text Files", "*.txt;*.csv;*.tab;*.asc", 1
    .title = "Choose Transactions file to import"
    .InitialView = msoFileDialogViewDetails
    .Show
    For Each objfl In .SelectedItems
    filnam = objfl
    Next objfl
    On Error GoTo 0
    End With

    Set fd = Nothing

    ''' filnam then used in following code . Note that although .AllowMultiSelect is set to False, you still need to run through the For each loop.

    Hope this helps

    change the .filters to add doc.. for word documents



    I am extremely sorry, i am not looking for the above coding type, infact i want to browse folder code which should open inside folders text file in word document automatically.

    Means i dont want to select or open text file manually and i want the code which open automatically with the help of its code.

    Kindly help me in this way.

    Thanks in advance for the help.

    Regards,
    Rahaman.

    E mail : Naseerrahaman@gmail.com

  4. #4
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    most people use the shell command
    dim returnval as variant

    returnval = Shell("whatever command you would run in a command window here")

    give that a try

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Extract text from each word document in a file
    By mercapto in forum Programming
    Replies: 11
    Last Post: 03-12-2013, 10:29 PM
  2. Browse and Open Folder Based on Matching Form Field
    By Tomfernandez1 in forum Access
    Replies: 11
    Last Post: 02-26-2013, 01:04 PM
  3. Replies: 4
    Last Post: 09-18-2012, 11:30 PM
  4. open folder/Make new folder(example)-VBA Code
    By Madmax in forum Code Repository
    Replies: 3
    Last Post: 03-13-2012, 09:17 AM
  5. Open a word document from access
    By natalia in forum Programming
    Replies: 1
    Last Post: 10-13-2010, 08:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums