Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Save Excel

Save Excel

Scheduled Pinned Locked Moved Visual Basic
help
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MsmVc
    wrote on last edited by
    #1

    Hi all I am trying to save excel through this code.

    Dim sPath As String
    Dim stPath As String
    Dim strPath As String
    Dim ws As Worksheet

    Set ws = ActiveSheet 
     
    sPath =  ThisWorkbook.Path & "\\" 
    stPath = Replace(ws.Range("A1"), "-", "") 
    strPath = sPath & Replace(stPath, ":", "-") & ".xls" 
    Call ThisWorkbook.SaveCopyAs(strPath) 
    

    But i am getting run time error.

    Run-time '1004'
    Method 'ThisWorkbook' of object _Global failed

    Please help me.

    L T T 3 Replies Last reply
    0
    • M MsmVc

      Hi all I am trying to save excel through this code.

      Dim sPath As String
      Dim stPath As String
      Dim strPath As String
      Dim ws As Worksheet

      Set ws = ActiveSheet 
       
      sPath =  ThisWorkbook.Path & "\\" 
      stPath = Replace(ws.Range("A1"), "-", "") 
      strPath = sPath & Replace(stPath, ":", "-") & ".xls" 
      Call ThisWorkbook.SaveCopyAs(strPath) 
      

      But i am getting run time error.

      Run-time '1004'
      Method 'ThisWorkbook' of object _Global failed

      Please help me.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I can't without knowing what the variables ThisWorkbook and ActiveSheet are.

      Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

      1 Reply Last reply
      0
      • M MsmVc

        Hi all I am trying to save excel through this code.

        Dim sPath As String
        Dim stPath As String
        Dim strPath As String
        Dim ws As Worksheet

        Set ws = ActiveSheet 
         
        sPath =  ThisWorkbook.Path & "\\" 
        stPath = Replace(ws.Range("A1"), "-", "") 
        strPath = sPath & Replace(stPath, ":", "-") & ".xls" 
        Call ThisWorkbook.SaveCopyAs(strPath) 
        

        But i am getting run time error.

        Run-time '1004'
        Method 'ThisWorkbook' of object _Global failed

        Please help me.

        T Offline
        T Offline
        The Man from U N C L E
        wrote on last edited by
        #3

        Call is a deprecated code word and should never be used. It is only there to support migration of code from non-object orientated VB6 applications. Get rid of it and you code will probably work.

        If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles]  [My Website]

        1 Reply Last reply
        0
        • M MsmVc

          Hi all I am trying to save excel through this code.

          Dim sPath As String
          Dim stPath As String
          Dim strPath As String
          Dim ws As Worksheet

          Set ws = ActiveSheet 
           
          sPath =  ThisWorkbook.Path & "\\" 
          stPath = Replace(ws.Range("A1"), "-", "") 
          strPath = sPath & Replace(stPath, ":", "-") & ".xls" 
          Call ThisWorkbook.SaveCopyAs(strPath) 
          

          But i am getting run time error.

          Run-time '1004'
          Method 'ThisWorkbook' of object _Global failed

          Please help me.

          T Offline
          T Offline
          Trevortni
          wrote on last edited by
          #4

          I didn't realize Excel was so badly endangered, but if you think this code will somehow manage to save it, then by all means do what you can. EDIT: Sorry, couldn't resist.

          J 1 Reply Last reply
          0
          • T Trevortni

            I didn't realize Excel was so badly endangered, but if you think this code will somehow manage to save it, then by all means do what you can. EDIT: Sorry, couldn't resist.

            J Offline
            J Offline
            Johnny J
            wrote on last edited by
            #5

            DAMN, I would have answered exactly the same, but you beat me to it... :laugh:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups