+ Reply to Thread
Results 1 to 5 of 5

.Refresh BackgroundQuery:=False error

  1. #1
    Registered User
    Join Date
    01-08-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    7

    .Refresh BackgroundQuery:=False error

    HI ,

    can any expert help on below vba. i alway got the runtime error '1004'but sometime it is running fine. just wondering if my data link is on network drive , is it due to the long time to access the network data causing the vbba not working?

    Private Sub CommandButton1_Click()

    Sheets("Summary").Select
    Sheets("Summary").Range("C1:S9287").Select
    Selection.ClearComments
    Sheets("EC").Select
    Range("B2:AF9287").Select
    Selection.ClearContents
    Range("A1").Select

    For colNum = 2 To (2 + Cells(18, 1)) '23
    'MsgBox (colNum)

    If ((IsEmpty(Cells(1, colNum)) = False) And (IsEmpty(Cells(2, 1)) = False)) Then

    fileDest = "TEXT;\\Fslfabtools\" & Cells(1, colNum) & "-FC3000\main\bin_debug\data\" & Cells(2, 1)

    'MsgBox (fileDest)
    With ActiveSheet.QueryTables.Add(Connection:= _
    fileDest, Destination:=Cells(2, colNum))

    .Name = "System_1"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlOverwriteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = False
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 437
    .TextFileStartRow = 1
    .TextFileParseType = xlDelimited
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1)
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With


    'insert comments
    If Sheets("Summary").Cells(4, colNum) = True Then
    For curRow = 2 To 9287
    If Sheets("Summary").Cells(curRow, colNum) = False Then

    If (IsEmpty(Sheets("EC").Cells(curRow, colNum)) = False) Then
    texts = Sheets("EC").Cells(curRow, colNum)
    'Sheets("Summary").Cells(curRow, colNum).ClearComments
    Sheets("Summary").Cells(curRow, colNum).AddComment (texts)
    Sheets("Summary").Cells(curRow, colNum).Comment.Shape.TextFrame.AutoSize = True
    End If
    End If
    Next curRow
    Else
    'Sheets("Summary").Cells(1, colNum).AddComment ("Different Software Version")
    'Sheets("Summary").Cells(1, colNum).Comment.Shape.TextFrame.AutoSize = True
    End If

    End If

    Next colNum

    Sheets("Summary").Select
    Sheets("Summary").Range("A1").Select
    MsgBox ("Complete!")

    End Sub

  2. #2
    Registered User
    Join Date
    09-17-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: .Refresh BackgroundQuery:=False error

    Please share file for better understanding.

  3. #3
    Registered User
    Join Date
    01-08-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: .Refresh BackgroundQuery:=False error

    1) Basically i ahve a look up dropdown delection on sheet1. config A will have so many tool id , config b will have certain tool ID ....
    2) i need the macro to extract out the data for all the tool with config A etc
    3) after run, it alway error out. could it be due to data on network disk?


    Private Sub CommandButton1_Click()

    Sheets("Summary").Select
    Sheets("Summary").Range("C1:S9287").Select
    Selection.ClearComments
    Sheets("EC").Select
    Range("B2:AF9287").Select
    Selection.ClearContents
    Range("A1").Select

    For colNum = 2 To (2 + Cells(18, 1)) '23
    'MsgBox (colNum)

    If ((IsEmpty(Cells(1, colNum)) = False) And (IsEmpty(Cells(2, 1)) = False)) Then

    fileDest = "TEXT;\\Fslfabtools\" & Cells(1, colNum) & "- tooldata\main\bin_debug\data\" & Cells(2, 1)

    'MsgBox (fileDest)
    With ActiveSheet.QueryTables.Add(Connection:= _
    fileDest, Destination:=Cells(2, colNum))

    .Name = "System_1"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlOverwriteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = False
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 437
    .TextFileStartRow = 1
    .TextFileParseType = xlDelimited
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1)
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With


    'insert comments
    If Sheets("Summary").Cells(4, colNum) = True Then
    For curRow = 2 To 9287
    If Sheets("Summary").Cells(curRow, colNum) = False Then

    If (IsEmpty(Sheets("EC").Cells(curRow, colNum)) = False) Then
    texts = Sheets("EC").Cells(curRow, colNum)
    'Sheets("Summary").Cells(curRow, colNum).ClearComments
    Sheets("Summary").Cells(curRow, colNum).AddComment (texts)
    Sheets("Summary").Cells(curRow, colNum).Comment.Shape.TextFrame.AutoSize = True
    End If
    End If
    Next curRow
    Else
    'Sheets("Summary").Cells(1, colNum).AddComment ("Different Software Version")
    'Sheets("Summary").Cells(1, colNum).Comment.Shape.TextFrame.AutoSize = True
    End If

    End If

    Next colNum

    Sheets("Summary").Select
    Sheets("Summary").Range("A1").Select
    MsgBox ("Complete!")

    End Sub
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-17-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: .Refresh BackgroundQuery:=False error

    I would suggest you to do the same manually and check wheather it a network file path issue or somthing else.

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: .Refresh BackgroundQuery:=False error

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro error with Refresh BackgroundQuery:=False
    By Mulberry in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-13-2013, 06:53 PM
  2. Run-time error '1004' for .Refresh BackgroundQuery:=False for loop
    By Robo25 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2013, 01:16 AM
  3. Replies: 1
    Last Post: 12-03-2011, 10:32 AM
  4. Error in Macro: (Refresh BackgroundQuery:=False)
    By abehnamian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2008, 12:45 PM
  5. Error with Selection.QueryTable.refresh BackgroundQuery:=False
    By rivets in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2007, 01:40 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