Results 1 to 13 of 13

Use Macro to open a file with excel (underfined type of file)

Threaded View

  1. #1
    Registered User
    Join Date
    07-29-2014
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    34

    Use Macro to open a file with excel (underfined type of file)

    Dear Professionals

    I wish to write a macro to do the following steps:

    1. open a (fileA) (undefined type) with excel.
    2. After opened the file, copying the content into the active workbook (Database).

    I have tried the following code, it fails

    Sub openQIR()
    '
    ' openQIR 巨集
    '
    
      
    Dim wbSource As Workbook, wbDestination As Workbook
              
               
        Set wbSource = Workbooks.Open("C:\user\desktop\tatfish\fileA.xlsx")
        Set wbDestination = ThisWorkbook
        
        With wbSource.Sheets(1).Select
        Range("A1:H1", Range("A20000:H20000").End(xlUp)).Select
        Selection.Copy
            
        Windows("Database.xlsm").Activate
        Sheets("2").Select
        Range("A" & Rows.Count).End(xlUp).Offset(2).Select
        Selection.PasteSpecial Paste:=xlPasteValues
        Selection.PasteSpecial Paste:=xlPasteFormats
        Application.CutCopyMode = False
        
    End With
            
        Sheets("1").Select
        'Close source:
        wbSource.Close
    '
    
    End Sub
    I understand it must fail because the type of fileA is not .xlsx
    The file A is underfined type but it can be opened with excel (currently do it manually).

    Please kindly teach me to amend my code for making it done.
    Thousands thanks.
    Last edited by tatfish87; 12-17-2014 at 05:16 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro needed to open "File Save As" and change save file type
    By blainerhett in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-28-2014, 02:40 PM
  2. Save as macro that specifies file type, file location and takes file name from three cells
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-13-2013, 10:09 PM
  3. VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV
    By daleski in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2013, 12:58 PM
  4. macro to open, copy paste from existing excel file to a new blank file
    By 2blessed in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2012, 06:05 PM
  5. Replies: 4
    Last Post: 02-18-2005, 10:06 PM

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