Results 1 to 11 of 11

Correct save path and syntax to save workbookdirectly into ONEDRIVE subfolder

Threaded View

  1. #1
    Registered User
    Join Date
    05-29-2012
    Location
    uk
    MS-Off Ver
    Excel 2013
    Posts
    12

    Correct save path and syntax to save workbookdirectly into ONEDRIVE subfolder

    Hi everyone, some words of wisdom please....

    I have a workbook with several sheets and macros. Some of these macros attempt to save/open files to/from a subfolder inside a local ONEDRIVE folder.
    I need to be able to set this up on multiple machines (all with different OneDrive accounts)and for them all to work.....

    When I test the following on a 'dummy' onedrive folder (that is not actually connected to OneDrive) this path/address it works.

    Trying it on a 'real live' onedrive folder gives me an error.

    Sub SaveWorkbookAsSchoolAndTeacherCode()
    Dim NewName As String
    Application.DisplayAlerts = False
    FilePath = Environ("USERPROFILE") & "\OneDrive\!Registers"
    NewName = "\HMS Register 2015-6 - " & Worksheets("Register").Range("G5").Value & " - " & Worksheets("Register").Range("G2").Value & ".xlsm"
    ActiveWorkbook.SaveAs FileName:=FilePath & NewName
    ThisWorkbook.Saved = True
    Application.Quit
    End Sub
    I have also tried this with no sucess

    Sub SaveWorkbookAsSchoolAndTeacherCode()
    Dim NewName As String
    Application.DisplayAlerts = False
    FilePath = "c:\User\\OneDrive\!Registers"
    NewName = "\HMS Register 2015-6 - " & Worksheets("Register").Range("G5").Value & " - " & Worksheets("Register").Range("G2").Value & ".xlsm"
    ActiveWorkbook.SaveAs FileName:=FilePath & NewName
    ThisWorkbook.Saved = True
    Application.Quit
    
    End Sub
    and this is broken too .... ;(

    Sub SaveWorkbookAsTempRegisterToMergeReportsForm()
        Application.DisplayAlerts = False
        Dim ExcelSaveAsName As String
        ExcelSaveAsName = Environ("USERPROFILE") & "\OneDrive\!Reports\hidden\TempRegisterToMergeReportsForm.xlsm"
        ActiveWorkbook.Save
    End Sub
    Please can anyone help?

    Many thanks in advance :

    Gideon
    Last edited by osbertdebroilg; 05-29-2015 at 06:31 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Save the open sheet in a path with a save as dialogue box and also create two folders
    By Biplab1985 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-19-2015, 05:19 PM
  2. VBA to open, edit and save to onedrive
    By MedOpsManZA in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-07-2015, 01:27 PM
  3. [SOLVED] Make another copy and save in diffrent path when i apply save
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-16-2014, 09:00 AM
  4. how to specify a file save path to a save macro
    By Solidstan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-04-2013, 05:33 PM
  5. Macro - Save Workbook to subfolder
    By PRodgers4284 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2009, 07:01 AM

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