+ Reply to Thread
Results 1 to 4 of 4

Inserting a backslash into a string of text (a path, actually)?

Hybrid View

  1. #1
    Registered User
    Join Date
    08-27-2012
    Location
    Santa Ana, CA USA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Inserting a backslash into a string of text (a path, actually)?

    I'm sure this is really simple, but I've tried different syntax (guessing) to no avail. Basically, I have a userform that will allow people to choose a folder location from a combobox and then specify their own file name, with the rest of the path being predetermined in the macro. I did this to reduce the number of mistakes people make when filling out a template form and saving it as a regular .xlsx. The macro also does a few simple things such as deleting the commandbutton and resizing/un-freeze paning the first row before it gets saved.

    Private Sub SaveButton_Click()
    
    'Turns off pop-up window asking if you're aware saving as a .xlsx file type will remove the macros in this workbook
    Application.DisplayAlerts = False
    
    'Searches for and deletes the Save button on the worksheet
    Dim myshape As Shape
        For Each myshape In ActiveSheet.Shapes
     
            If myshape.Type = 12 Then myshape.Delete
     
        Next myshape
        
    'Selects and turns off the freeze paned row
    Rows("1:1").Select
    ActiveWindow.FreezePanes = False
    
    'Resizes the first row to default size so it looks like the button was never there
    Rows("1:1").RowHeight = 15
    
    'Selects cell A1 so nothing is hilighted
    Range("A1").Select
    
    'Saves the current workbook as a .xlsx (macro-free) workbook
    ActiveWorkbook.SaveAs "\\server01\mycompanyname\PUBLIC\PERSONAL FOLDERS\Test Save Location\" & ComboBox1.Value "\" & TextBox1.Value, FileFormat:=51
    
    'Closes the userform (popup save window)
    Unload Me
    
    End Sub
    The issue lies within the "\" between the combobox and textbox values (I get a syntax error). What would be the proper way of phrasing it to insert the backslash?


    Thanks, all!

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Inserting a backslash into a string of text (a path, actually)?

    Just need another ampersand after ComboBox1.Value

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Inserting a backslash into a string of text (a path, actually)?

    Missing "&"

    ComboBox1.Value & "\" & TextBox1.Value

  4. #4
    Registered User
    Join Date
    08-27-2012
    Location
    Santa Ana, CA USA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Inserting a backslash into a string of text (a path, actually)?

    D'oh!

    I'm glad the weekend's here as I apparently am in need of rest.

    Thank you for the help, guys!

+ 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