Closed Thread
Results 1 to 2 of 2

Create a new folder on Google Drive using Excel VBA Coding

  1. #1
    Registered User
    Join Date
    10-22-2018
    Location
    Alberta, Canada
    MS-Off Ver
    2010
    Posts
    3

    Post Create a new folder on Google Drive using Excel VBA Coding

    Hi everyone,

    I am a fairly new user to Excel vba. I am trying to create for my company a macro enabled excel sheet which will save itself as a macro free sheet as well as a pdf in the new folder that it will make on the Google Drive. I am using the following code below, but it is:
    (i) not creating the new folder on Google Drive
    (ii) not naming the excel sheet as it does the pdf

    Please help me on this, I am quite frustrated as I have spent a lot of days trying to figure my way out. Thanks in advance (my code is below).


    Sub SaveOnGoogleDrive()

    ' print pdf file

    Dim WSHShell As Object
    Dim strPath As String
    Dim sFileName As String
    Dim sFullPath As String

    ' get Documents folder path (16)
    Set WSHShell = CreateObject("Wscript.Shell")
    strPath = WSHShell.SpecialFolders(16)
    Set WSHShell = Nothing
    ' change to "Google Drive"
    strPath = Replace(strPath, "Documents", "Google Drive\Purchase Order\Test PO & Tracker\")


    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    On Error Resume Next

    ' set current workbook file name
    sFileName = Range("F6:F6") & "-" & Range("B12:B12") & "(" & Range("B10:B10") & ")" & "-" & Range("B6:B6")
    ' change to pdf file name: replace ".xlsm" by criterion + ".pdf"
    sFileName = Replace(sFileName, ".xlsm", " " & "Test" & ".pdf")
    ' note: the above won't work if the workbook has not been saved

    ' create full path name
    sFullPath = strPath & Application.PathSeparator & sFileName

    With ActiveSheet
    ' save as a PDF file
    ' minimum quality to keep the file small
    .ExportAsFixedFormat _
    Type:=xlTypePDF, _
    FileName:=sFullPath, _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=False

    Worksheets(Array("Sheet1")).Copy
    ActiveWorkbook.SaveAs FileName:=strPath & "\" & sFileName & ".xlsx"

    End With

    On Error GoTo 0
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True

    End Sub

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Create a new folder on Google Drive using Excel VBA Coding

    Welcome to the Forum, unfortunately this is a duplicate post and as such will now be closed, you may continue in your other thread.

    Thread Closed.
    HTH
    Regards, Jeff

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Nothing
    By waleed.slc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2018, 06:30 PM
  2. Using Excel w/in Google Drive on an iPad Air
    By jmg999 in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 02-12-2018, 02:16 AM
  3. Replies: 2
    Last Post: 02-18-2017, 04:11 AM
  4. How to create a folder on your hard drive for mails?
    By terry3218 in forum Outlook Formatting & Functions
    Replies: 6
    Last Post: 02-10-2017, 04:19 AM
  5. Help required; looking up names from other excel files, in Google Drive
    By pyrzi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-06-2015, 07:56 AM
  6. Create new folder (on hard drive), and save email to it.
    By ashleyuk1984 in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2013, 04:10 AM
  7. [SOLVED] VBA to create a folder on a network drive before saving the file to it?
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-29-2011, 10:23 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