The number must be between 1 and 2147483647. Try again by entering a number in this range.

The number must be between 1 and 2147483647. Try again by entering a number in this range.

The number must be between 1 and 2147483647. Try again by entering a number in this range. Excel VBA

It is really annoying as you are trying to export your data in pdf using standard object ExportAsFixFormat method offered by Microsoft Excel and getting above error. I tried a lot a straight forward command is not exporting my data into a file!!! finally I managed to bring it in my desired shape.

Code example

Public Function ExportFileExample(xlSheet As Worksheet, rngName As String, showFile As Boolean) As Boolean
	ExportFileAsPDF = False
	On Error GoTo errh
		Dim tmpFolderPath As String
		tmpFolderPath = Environ("APPDATA")
		Dim tmpFileName As String
		tmpFileName = "tmp" & Format(Now, "ddmmhhmmss") & ".pdf"
		xlSheet.Range(rngName).ExportAsFixedFormat Type:=xlTypePDF, Filename:=tmpFolderPath & "\" & tmpFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=showFile
		ExportFileAsPDF = True
	If Err.Number <> 0 Then
		ExportFileAsPDF = False
	End If
End Function

Calling Method

Sub CallingMethod()
    If ExportFileAsPDF(ActiveSheet, "A1:G400", True) = False Then
        MsgBox "Fail to export"
        MsgBox "Export Success"
    End If
End Sub

So what is the difference I have made here? If you give a closer look to my calling method the second parameter I am sending Range as Hard Code string that is the fix:)

Next : Download file from API (Web Service) and Save in Desired Format using VBA

16 thoughts on “The number must be between 1 and 2147483647. Try again by entering a number in this range.

  1. Hello there, I discovered your site by the use of Google even as looking for a related subject, your site got here up, it appears to
    be like great. I’ve bookmarked it in my google bookmarks.

    Hello there, just became alert to your blog through Google, and
    found that it is really informative. I’m going to be careful for brussels.

    I’ll be grateful if you happen to continue this in future.
    A lot of folks might be benefited from your writing. Cheers!

  2. We’re a group of volunteers and starting a new
    scheme in our community. Your web site offered us
    with valuable information to work on. You’ve performed a formidable process and our entire community might be thankful to you.

  3. Superb blog! Do you have any tips and hints for aspiring writers?

    I’m planning to start my own site soon but I’m a little lost on everything.
    Would you suggest starting with a free platform like WordPress or go for
    a paid option? There are so many choices out there that I’m totally confused ..
    Any recommendations? Thank you!

  4. This implies that the relevant site conteht will more likely adequately
    indexed the robots. Yet noticed the starting associated withh each end product?
    It is advisable to know where your visitors coming by way of.

  5. Right here is the perfect site for anybody who really wants to understand this topic.
    You understand a whole lot its almost hard to argue with you (not
    that I personally would want to…HaHa). You definitely put a
    fresh spin on a subject which has been discussed
    for a long time. Wonderful stuff, just wonderful!

  6. I’m amazed, I have to admit. Seldom do I encounter a blog that’s both equally educative and amusing, and
    without a doubt, you’ve hit the nail on the head. The issue
    is something that too few folks are speaking intelligently about.

    Now i’m very happy I stumbled across this during my search for something regarding this.

  7. When someone writes an paragraph he/she maintains the thought of a user
    in his/her mind that how a user can know it. So that’s
    why this paragraph is great. Thanks!

Leave a Reply

Your email address will not be published.