+ Reply to Thread
Results 1 to 12 of 12

How to open or Print a doc or pdf file from a combobox on a userForm

  1. #1
    Registered User
    Join Date
    01-12-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007
    Posts
    26

    How to open or Print a doc or pdf file from a combobox on a userForm

    I have a folder full of doc files. I used a userform on which i put a combobox which contains those files' names and a cmd to open the file.

    I managed to copy all the files names to the WorkSheet and listed them in the combobox.

    @@@ I need a VBA code to do the following :

    1- looking for the file name which matches the one i choose from the combobox
    2- if there is a match, show " match" on a lable.
    3- when i click the "open" cmd i created on the userform, it opens the file. or even print it and close it
    4- prepare for another match.

    I know it a lot of work and i am not that good in VBA, but THANKS in Advance

    ### ###
    Last edited by Abo Rawad; 01-24-2012 at 11:49 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    Hello Abo Rawad, welcome to the forum.

    I'm afraid your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  3. #3
    Registered User
    Join Date
    01-12-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    I am sorry , it is my bad.
    I didn't read the rules.
    this is the cross post link

    http://www.mrexcel.com/forum/showthread.php?t=608047

    sorry again

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    Maybe something like:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-12-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    should I attach your code to the cmd ?

    and there is not any mentioning to the combobox !!

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    Hello Abo Rawad,

    Welcome to the Forum!

    It would be easier to answer your question and provide an solution if you post the workbook.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  7. #7
    Registered User
    Join Date
    01-12-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    consider the following;

    I have .doc files named file1, file2, file3, file4 up to file12 in the folder " E:\Myfolder ".

    i made two comboboxes( combo1, combo2) and a commandButton (cmdOpen). i makes 3 ranges in the worksheet (4 file names in each one).
    i added the items 1,2,3 to the combo1, i linked it to combo2 so that whenever i choose a number from combo1, a range will be listed in combo2 using the RowSourse property, so, eventually the file names will be listed in combo2. So far so good, Sir.

    I want to add a code in the cmdOpen, so when i click it, it looks in the folder that contains the files (E:\Myfolder) for a match to the file name I chose from combo2 (e.g. file1). and if there is a match , open the file.


    **** I am not using ActiveX cotrols. ****

    Thank you very much for your patience, Sir.
    Last edited by Abo Rawad; 01-26-2012 at 12:30 PM.

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    Please post a sample workbook as Leith suggested

  9. #9
    Registered User
    Join Date
    01-12-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    Here is what i tried :

    Please Login or Register  to view this content.


    this code does open the file. But i still have two problems with it :-
    1- the file type is .pdf and what i need is .doc.
    2- Instead of using "file1" which is the file name in the code , i want a variable that hold "combo2.value" and use it in the place of the file name. that way, when
    clicking cmdOpen, it will check in (E:\folder) for a match to the filename displayed in the combo2 to , if there is a match ,it open the file .

    Hope i made it clear this time

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    not really, please post a sample workbook

  11. #11
    Registered User
    Join Date
    01-12-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    I attached the the Workbook.


    I appreciate everything you are doing. thanks
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    01-12-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: How to open or Print a doc or pdf file from a combobox on a userForm

    Come on guys, you are the expertise. in that code i open a certain file.
    Can anybody do the coding magic to solve my problem. ?

    Your efforts are fully appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1