+ Reply to Thread
Results 1 to 2 of 2

How do you disable date recognition in VBA?

Hybrid View

pfrattali How do you disable date... 01-14-2011, 10:27 PM
pfrattali Re: How do you disable date... 01-15-2011, 01:01 AM
  1. #1
    Registered User
    Join Date
    09-29-2008
    Location
    Toronto, Canada
    Posts
    14

    How do you disable date recognition in VBA?

    I'm using a macro to do a simple copy and paste of a website page (whole page in Internet Explorer). I call up IE and navigate using the VBA macro. Part of the data shows expressions like '1 / 2' or ''2 / 3' which is saying 'one out of two' and 'two out of three', etc.

    The problem is when they are pasted on a worksheet, excel converts them to dates such as '1-Feb' or '2-Mar' . Don't want this.

    I tried to pre-format the cells to text before running the macro, but it didn't work. It gave me a 5 digit date # ?


    How do I disable the date recognition using a macro to copy from a website?

    I am not using 'web query' by the way, and I know how to disable the date recognition by this method.

    I'm using the following code basically:

    ' grab the whole screen & paste into Excel
    ie.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
    ie.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
    
    
      'Wait for page to load!
      Do
     
        If ie.ReadyState = 4 Then
           ie.Visible = False
           Exit Do
        Else
           DoEvents
        End If
    
      Loop
    
    
    ie.Quit
    
    
    ActiveSheet.Paste



    thanks for your help.

  2. #2
    Registered User
    Join Date
    09-29-2008
    Location
    Toronto, Canada
    Posts
    14

    Re: How do you disable date recognition in VBA?

    never mind. Found the solution.

    After copying the web page, the following code will take care of the problem. The figures will show correctly

    ActiveSheet.PasteSpecial Format:="html", Link:=False, DisplayAsIcon:= _
            False, NoHTMLFormatting:=True



    BEFORE this, you need to format the cells in question as 'Text'.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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