Network Printer 'ActivePrinter' Of Object'_Application' Failed
May 18, 2007
I am having trouble printing a page to both a local printer (which works fine) and a network printer (which does not work) Both printers are installed on the Computers. The error message I get when I try to run the macro is Run-Time ERror '1004': 'ActivePrinter' of object'_Application' failed. The codes that I have used are
Application.ActivePrinter = _
"\SAUWTPFS01.sopac.pilkington.netDespatch Toughend & Batch reports (L164) on Ne05:"
and
Application.ActivePrinter = _
" \sauwtpfs01pauwtp0305 on Ne05:"
and
Application.ActivePrinter = _
" \sauwtpfs01pauwtp0305"
It works on the day I record the macro. As soon as the next day comes around I get the error message. When I click debug it is these lines that are highlighted in yellow. I have looked at this for several days on and off and I always get the same error.
View 7 Replies
ADVERTISEMENT
Oct 30, 2008
Is there a way to test for an active default network printer?
In my module the code sets the paper size and a few other printer settings, if my default network printer is down or offline the code fails.
If I could test for active default printer I could remove this error.
View 9 Replies
View Related
Jul 26, 2007
I have a new workbook that needs to be printed to a specific printer regardless of who the user is. I am happy with the method used for doing this using the PrintOut function, but am trying to work out what to do in the event that the user does not have this printer installed. The logic, not in true VBA syntax, is as follows;
' Check Printer
If <This Printer> Is installed Then
Printout using <This Printer>
Else
Install <This Printer>
Printout using <This Printer>
I found a useful post about ascertaining whether or not a printer is installed, but can't find anything about actually installing a printer via VBA.
View 7 Replies
View Related
Mar 2, 2007
The following code below was very kindly created for me by someone approx 12 months ago and I have been using it without any problems at all.
The purpose of the code is to creates a new Menu/Title item named "Quality" on the main Excel menu bar at the top of Excel and place it between the "Windows" and "Help"
This new Quality menu then has further drop lists which i can add as suited.
Two days ago i started getting the following RunTime Error everytime i open Excel and i can not longer get the new menu "Quality" to show on my Excel menu bar.
run-time error '2147467259 (80004005)':
Method 'Add' of object 'CommandBarControls' failed ........
View 9 Replies
View Related
Jan 24, 2009
I have a while loop in which I'm updated information in 2 separate worksheets. I'm using the With-block statements separately to update each, but after the 30th iteration (and it's always on the 30th), the VBA code halts and get the "method 'value' of object 'range' failed" error message pointing to a line with the code as follows:
With Sheet1
.Cells(lngRow, 9).Value = intMonths
End With
where "intMonths" is an integer variable which I'm populated properly, and "lngRow" a long variable. When I debug both variables have proper data in them, and I have no idea why this is bombing.
View 9 Replies
View Related
Apr 2, 2005
When I try to pull some records from Oracle into Excel using ADO, I recieved this error msg:
Run-time error '-2147467259 (80004005)':
Method 'CopyFromRecordset' of object ' Range' failed
And here's the code I'm using:
Dim c As ADODB.Connection
Dim r As ADODB.Recordset
Dim sq As String
Set c = New ADODB.Connection
It's the standard ADO example used in this forum many times. Obviously there is some type of issue when the records are returned. I know that it isn't an issue with the number of records returned. It can return 30,000 fine but a few hundred may return this error. It's kinda random.
View 9 Replies
View Related
Oct 24, 2008
I'm currently working on a fairly complex VBA project in Excel 2007. Basically though, I'm downloading information from a site, massaging it, creating a lot of graphs, saving them locally, deleting the chart from excel. I then save a copy of the workbook to a local file, clear the Spreadsheet, and then Do the same for information from another site.
When I had all of the code in one Module and ran it as a macro it ran flawlessly.
Now i've put the information into a Class. And am pretty much running the same process via a UserForm.
The problem I have though is that at any point after I execute the (and please assume that all variables have been declared, because they have)
View 14 Replies
View Related
Jun 23, 2009
I can't seem to figure out why this keeps giving me that error...
I've checked the row and column values inside and they seem to be ok. blank_ee() is an array of strings.
View 7 Replies
View Related
Jan 30, 2013
It is designed to submit data specific cells from a userform. It works fine when I select and day, 1,2,3, etc. until I get to day 27-31. For some reason I get a Range of Object Failed error 1004 every time. I don't understand what's changing to cause the issue. The red text near the bottom is the one that it tells me is the problem.
Code:
Private Sub Submit_Click()
Dim ws As Worksheet
Set ws = activesheet
[Code]....
View 9 Replies
View Related
Feb 9, 2010
I need some help with this error. I have some VBA code in Outlook that runs whenever a task reminder goes off. The code is supposed to open a workbook, send email based on the info in the workbook, then close the workbook and quit excel.
The task reminders are set to go off every two hours. Sometimes this will work fine for days and then randomly (as far as I can tell) I get the error: "Method Open of Object Workbooks failed". If I press Debug and then Run without changing anything at all, it works fine.
I am using Outlook 2007 and Excel 2007. The workbook is a shared workbook on a network drive.
I can post code if needed, but will have to go to that computer.
Why do I occasionally get this error when the workbook definitely exists and has the same name and path?
What does entering debug mode do that then allows the macro to run without error?
View 9 Replies
View Related
Sep 10, 2006
Sub a()
z = 4
y = 7
sWork. Range(Cells(1 + nRow(z), 4), Cells(1 + nRow(z), 12)).Replace y, 0 lookat:=xlPart, searchorder:=xlByRows, MatchCase:=False
End Sub
but when I include it in my main code
sWork.[A1:L9] = 123456789
For z = 1 To 81
y = [A1].Offset(nRow(z), nCol(z))
If y > 0 Then
sWork.Cells(1 + nRow(z), 1).Replace y, 0, lookat:=xlPart,searchorder:=xlByRows, MatchCase:=False, matchbyte:=False
sWork.Cells(1 + nCol(z), 2).Replace y, 0, lookat:=xlPart, searchorder:=xlByRows, MatchCase:=False, matchbyte:=False
sWork.Cells(1 + nBox(z), 3).Replace y, 0, lookat:=xlPart, searchorder:=xlByRows, MatchCase:=False, matchbyte:=False
sWork.[A1].Offset(nRow(z), nCol(z) + 3).Value = 0
sWork.Range(Cells(1 + nRow(z), 4), Cells(1 + nRow(z), 12)).Replace y, 0, lookat:=xlPart, searchorder:=xlByRows, MatchCase:=False
sWork.Range(Cells(1, 4 + nCol(z)), Cells(9, 4 + nCol(z))).Replace y, 0, lookat:=xlPart, searchorder:=xlByColumns, MatchCase:=False
sWork.Range(Cells(1 + Int(nRow(z) / 3) * 3, 4 + Int(nCol(z) / 3) * 3), Cells(3 + Int(nRow(z) / 3) * 3, 6 + Int(nCol(z) / 3) * 3)).Replace y, 0, lookat:=xlPart, searchorder:=xlByRows, MatchCase:=False
End If
Next
I get a "Method 'Range' of object '_Worksheet' failed" error at line 9,
when z = 4, y = 7, and nRow(z) is a UDF which = 0.
View 8 Replies
View Related
Nov 8, 2006
I have a button on my spreadsheet which activates some code, it has worked perfectly for over a year but now for some reason I cannot get it to work.
When I click on the button now I get the message: Run-time error '1004' Method ' Range' of object '_Global' failed.
the file is far too large to attach here but here is the relevant ...
View 8 Replies
View Related
Dec 16, 2006
why i'm getting this run time error :"Method 'goto' Of Object 'Application' Failed"?
Sub SynchSheets()
Dim wSheet As Worksheet
Dim rRange As Range
Dim dZoom As Double
Dim wSheetStart As Worksheet
Set wSheetStart = ActiveSheet
Application. ScreenUpdating = False
With ActiveWindow
Set rRange = .VisibleRange.Cells(1, 1)
dZoom = .Zoom
End With
View 3 Replies
View Related
Feb 15, 2007
From the current open book, I'm opening a 2nd book, then copying all worksheets from the 2nd book that meet criteria, into 1st book, (in the same order), but am getting Method 'Copy' of object '_Worksheet' failed error. What am I doing wrong?
How to OVERWRITE worksheets?We'll be running the same process with new data, so also need to overwrite worksheets in 1st book.
Sub Build_Branch_File()
Dim FileName As String
Dim Wkb As Workbook
Dim Ws As Worksheet
Dim WNum As String
Dim Tnum As String
Dim RegionNo As Integer
Dim Original_Wb As Workbook
With Application
. ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With
Set Original_Wb = ThisWorkbook .........................
View 9 Replies
View Related
May 19, 2007
item = InputBox("Please Select Row Number of Child to be Removed")
myString1 = Range("$a" & item & ":$c" & item, "$e" & item & ":$j" & item).Select
I copied this code from a prior worksheet and the range was not split (i.e. just "$a" & item & ":$c" & item). When I try to make the range selection grab two separate areas, I get the above listed error. Do I not have the quotations right? I have tried them several different ways. Not sure what else to try.
View 3 Replies
View Related
Jun 27, 2007
Sub Approve()
Calculate
If IsEmpty( Range("D67")) Then
Range("D67").Value = Application.UserName
ElseIf IsEmpty(Range("E67")) Then
Range("E67").Value = Application.UserName
Else:
Range("F67").Value = Application.UserName
End If
ActiveWorkbook.Route
End Sub
I am clicking on a an approve button which executes this code. But when I click the button the error reads: Run-Time error 1004, Method 'route'object'_workbook'failed.
View 9 Replies
View Related
Jul 6, 2007
I am having a problem with this bit of code. When I try to run it it shows Method Range of object Worksheet Failed.
The original code I adapted this from works just fine, and the only thing I have changed is the ranges and the sheet.
The code is:
Sub Filter()
With Sheet18
'
.Range("DisbData").AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=.Range("Criteria"), Unique:=False
.Range("DisbData").SpecialCells(xlCellTypeVisible).Copy Destination:="DisbPaste"
.ShowAllData
End With
End Sub
The line that the debugger is showing has issues is:
.Range("DisbData").AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=.Range("Criteria"), Unique:=False
View 4 Replies
View Related
May 2, 2009
I'm trying to set the print area on two sheets in the same workbook and it is returning Method 'Range' of object' _Global failed error every time and I can't figure out what code to change to make this error stop happening. here is my
View 5 Replies
View Related
May 20, 2008
I start in my "Action Plan for For Single Market" worksheet and if I click on the Command Button I then want to read in a couple of variables, and jump to a second worksheet (called "Market Action Plans") where I then want to copy a range, and then paste it in another area in that same sheet.
I thought I had worked out what to do, but when I execute I get a "run-time error 1004" when the macro gets to the "Range("Updated_Results").Copy" line. Excel describes the error as "Method 'Range' of object '_Worksheet' failed'" - which might as well be a foreign language as far as I am concerned!
Private Sub CommandButton2_Click()
Current_Market_Row = Range("Current_Market_Row")
First_Col_Action_Desc = Range("First_Col_Action_Desc")
Sheets("Market Action Plans").Select
Range("Updated_Results").Copy
Cells(Current_Market_Row, First_Col_Action_Desc).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Action Plan for Single Market").Select
End Sub
I am an occasional macro-creator and every now and again, I come across this type of problem where I can't get variables to be reconized, etc. I think it's because I don't understand enough about Private versus Public, and how to declare variables.
View 9 Replies
View Related
Mar 1, 2007
The following bit of code has been working fine but has now started getting the following error;
Method ' sheets'of object'_global' failed
This kicks in on line 3.
The worst thing is it will not let me get into the workbook at all
Sub KillForm()
'Update Names on Sheets
If Sheets("Daily Visits May").Range("e1") = "y" Then Goto 10
If Sheets("Daily Visits May").Range("d1") > 38837 Then Else Goto 10
Worksheets("Daily Visits Apr").Range("B5:C1500").Copy
Worksheets("Daily Visits May").Select
Range("B5").Select
ActiveSheet.Paste
View 9 Replies
View Related
Jul 28, 2007
Error 1004 on the 5th "With Selection" Chunk, .LineStyle part.
What I did is recorded the formatting I wanted on a selected region, then changed the major references to the defined region in my code called rngATotals.
At first I got errors with the "Select" method of the "Range" class with my rngATotals line (the first one). But then I clarified public variables and now its in the formatting chunk that was recorded.
I've tried:
--Changing security/protection settings
--Clarifying my rngATotals references
--Making the sheet containing rngATotals visible (still in my code snippet)
--And not using rngATotals to define my range but more specific, clunky references like Range ("A3":"B7") or Range(Cells...,Cells...) or Range ("RAnge'sName")
What further could I clarify? And why does it have a problem with the 5th borders/linestyle reference and not the previous ones?
I hate to have to ask another question about this error because there are so many...
Is there anything beyond what I've tried that is a usual way to approach this problem?
Anyway heres the
Sub FormatTotalsTables()
'
' FormatTotalsTables Macro
' Macro recorded 7/22/2007 by AEB
SumSheet.Visible = True
rngATotals.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
View 9 Replies
View Related
Oct 11, 2012
Why am I getting method range of object global failed error message? The error seems to lie in the line highlighted in red.
VB:
[CODE]Private Sub btnEditDelete_Click()
Dim customerID As String
Dim rowID As Integer
Dim foundFlag As Integer
Dim lastrecFlag As Integer
Application.ScreenUpdating = False
[Code] .....
View 4 Replies
View Related
Sep 26, 2009
I'm so new to VBA this is probably another simple question, but here goes...
The error-text is:
"Method 'Range' of object '_Global' failed"
It happens at:
rng = Range(gCSchedule.Ws.Cells(gCSchedule.DateRow, StartCol))
See following code.
View 8 Replies
View Related
Oct 3, 2011
I have written a sub with the purpose of finding rows based on a critieria, copying the rows to another worksheet and deleting the original row.
The code:
Code:
Sub MoveToIgangvaerende()
'
' Flytter opgaven til sheetet Igangværende projekter
'
Dim i, j, Index As Integer
Forfra:
For i = -1 To 1000
If Sheets("Pipeline").Cells(3 + i, 20) = "Ja" Or Sheets("Pipeline").Cells(3 + i, 20) = "ja" Then
[Code] ......
I get the error message "Method 'Delete' of object 'Range' failed" at the line "Sheets("Pipeline").Cells(3 + i, 18).EntireRow.Delete".
The sub has previously worked perfectly fine.
View 4 Replies
View Related
Jun 4, 2013
I started a new job and my new company uses Excel 2010 (64-Bit). The code below was written for use in Excel 2007. I am trying to open an XML file and simply paste the results in a spreadsheet but I am getting this error, "Method 'OpenXML' of object 'Workbooks' failed" at the "set oWX" line in the code.
Sub GetNetTIEDAH()
Dim idate As Integer
Dim strThisBook As String
[Code].....
View 1 Replies
View Related
Mar 16, 2009
Method range of object global failed
When i run this ....
View 9 Replies
View Related
Jun 28, 2006
I have a cet of CommandButtons on sheet 1. The code for these buttons is in the code section of the sheet. A named range is referenced in this code. This named range is on sheet 2. Every time I try to reference this or any named range (from any other sheet), I get this "Run-time error '1004': Method 'Range' of object '_Worksheet' failed"
The last time I had this error I was able to fix it by moving the code to Module1. I tried that here, but it did not work (I can't figure out how to call it from the sheet). CommandButton. Here is the code from the sheet for one of the buttons:
Private Sub TBEnterUp_Click()
iLast = Range("WBDate_DayLast").Value '<<<<<<<
iItem = TBEnter.Value
If iItem = iLast Then
TBEnterUp.Visible = False
Exit Sub
End If
TBEnter.Value = iItem + 1
If iItem > 0 Then TBEnterDown.Visible = True
End Sub
It is a simple number advancer. It is working in the UserForm I took it from. I have included a sample file of the problem. Feel free to look at it and borrow anything in it that you might like.
View 2 Replies
View Related
Sep 6, 2006
i get this error on the line in bold Method Add' of object 'CommandBarControls' failed (run-time error '-2147467259'). im not sure why its giving that problem, but im not very fluent in custom toolbars.
'//The following two procedures add a custom menu to the workbook programmatically//'
'//and then delete it//'
Public currentMonth As String
Sub CreateMenu()
Dim mybar As CommandBar
Dim myControl As CommandBarControl
Set mybar = Application.CommandBars.Add( Name:="CustomButtons", _
Position:=msoBarBottom, Temporary:=True)
mybar.Visible = True
Set myControl = mybar.Controls _
.Add(Type:=msoControlButton, ID:=1)
With myControl...........................
View 3 Replies
View Related
Feb 10, 2009
I am trying to build a macro which will format the columns of a spreadsheet - basically it inserts some columns, writes formulas and highlights them. Here is a code I have got so far...
When I try to run this I get a run time error 1004 - Method 'Range' of 'Object'_Global' failed. The part of the code
Range("N2:N").FormulaR1C1 = "=(RC[-7]/RC[-2])"
is highlighted in the debugger.
Can anyone tell me why this is happening, also it would be great if you could suggest better ways of writing this code - as I am new to vba programming and most of my macros are built using the recorder and then 'working' on them.
View 11 Replies
View Related
Mar 25, 2009
I have an interesting error that only happens when there is one row of data in the worksheet (sheet2 or "Half Payout"). Rows 1 & 2 are headers, row 3 is when the data starts - if any. With either no rows of data or more than one the coding works just fine. Here is the exact error message I'm getting: Run-time error '1004': Method 'Range' of object '_Worksheet' failed.
The following code is supposed to sort the rows of data when opened and then activate the first open cell below B2.
View 6 Replies
View Related