none
dont show workbook when opening RRS feed

  • Question

  • using this code to open a workbook and copy data. don't want to see workbook. 

    I know it has to do with .visible=false but not sure how to use

    thanks

    Doug

    Application.ScreenUpdating = False

    ThisWorkbook.Save

    MYPATH = MYPATHIS()

     strFolder = MYPATH

    Dim FNAME As String

    FNAME = ComboBox1.Value

    If Dir(MYPATH & FNAME) <> "" Then

     

    Workbooks.Open strFolder & FNAME

    Workbooks(FNAME).Sheets("sheet1").Range("A1:BZ1500").Copy Destination:=ThisWorkbook.Sheets(1).Range("A1")

    Workbooks(FNAME).Close True 'CLOSE WORKBOOK

    Call showdata

    End if


    • Edited by 6da4 Wednesday, March 21, 2018 12:40 PM typo
    Wednesday, March 21, 2018 11:45 AM

Answers

  • Since you're opening the excel in the same workbook you are working in, you need to hide the window:

    Workbooks(FNAME).Windows(1).Visible = false


    • Edited by Wouter Defour Wednesday, March 21, 2018 2:47 PM
    • Marked as answer by 6da4 Friday, March 23, 2018 10:11 AM
    Wednesday, March 21, 2018 1:20 PM

All replies

  • Since you're opening the excel in the same workbook you are working in, you need to hide the window:

    Workbooks(FNAME).Windows(1).Visible = false


    • Edited by Wouter Defour Wednesday, March 21, 2018 2:47 PM
    • Marked as answer by 6da4 Friday, March 23, 2018 10:11 AM
    Wednesday, March 21, 2018 1:20 PM
  • thanks

    will try this tonight. I assume your code would go between these two lines?

     

    If Dir(MYPATH & FNAME) <> "" Then

     

    Workbooks.Open strFolder & FNAME

    Wednesday, March 21, 2018 3:05 PM
  • Hello 6da4,

    >> I assume your code would go between these two lines?

    You need open the file at first and then hide the windows. So you need put the code behind Workbooks.Open strFolder & FNAME.

    Just like:

    Workbooks.Open strFolder & FNAME
    Workbooks(FNAME).Windows(1).Visible = False

    By the way, I would suggest you print the strFolder & FNAME to check whether it is valid filename if the code does not work as you want.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 22, 2018 6:40 AM
  • thanks Terry,

    my application creates its own folders and filenames and only shows those files in combobox1.

    strfolder and fname are always valid.

    really appreciate all you folks out there who offer assistance like this. learned a lot...a lot to learn!

    Doug

    Friday, March 23, 2018 10:20 AM
  • thanks Wouter

    works perfectly. appreciate your help!

    Doug

    Friday, March 23, 2018 10:21 AM