+ Reply to Thread
Results 1 to 6 of 6

Problems again with vb.net code vs vba regarding SaveAs

  1. #1
    Forum Contributor
    Join Date
    08-29-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    103

    Problems again with vb.net code vs vba regarding SaveAs

    This is my modified vba code:
    Please Login or Register  to view this content.
    I don't see anything wrong with it, however the code in ide is red and says:

    Compile Error,

    Expected: "="
    As far as I can tell, everything looks fine. Here's the full code leading up to that section if that helps:

    Please Login or Register  to view this content.
    I'm sure it's some small difference between vba and vb.net again, as even the msdn seems to support my code: msdn
    Last edited by Taemex; 12-13-2014 at 03:12 AM.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Problems again with vb.net code vs vba regarding SaveAs

    it works for me
    Please Login or Register  to view this content.

  3. #3
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Problems again with vb.net code vs vba regarding SaveAs

    Hi,

    To get the "Desktop" path in VBA, use this :

    Please Login or Register  to view this content.
    Regards
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Problems again with vb.net code vs vba regarding SaveAs

    Try:

    Please Login or Register  to view this content.
    parentheses would be needed only if you call this method as a function (want some reuslut returned).
    Last edited by Kaper; 12-13-2014 at 03:22 AM.
    Best Regards,

    Kaper

  5. #5
    Forum Contributor
    Join Date
    08-29-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    103

    Re: Problems again with vb.net code vs vba regarding SaveAs

    Thank you to everyone who's helped me so far. When I run this section of the code, everything seems to work fine until it saves, at which point it drops me a run-time error 1004:

    Microsoft Excel cannot access the file
    'C:\Users\MyName\Desktop\Transmittals\Gibberish'.
    Note where I put gibberish; every time I tun the code, that section outputs with something different, some random letters and numbers, but always starts with a number, then some letters, then numbers, and ends with an apostrophe (i.e. 9DD52000', or 63B72000'. I added a msgbox before it to be sure strCleanDate was outputting a valid string and it definitely does, as in: 12_13_2014.

    Here is the updated code, still giving me trouble, after the edits:
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-29-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    103

    Re: Problems again with vb.net code vs vba regarding SaveAs

    I've narrowed it down by removing all variables I could. In it's simplest form (below), I still get the error:

    Please Login or Register  to view this content.
    Which says to me something is getting screwed up between "\Transmittals\" and the & sign, but I'm not sure how this is possible.

    EDIT: I got it to save by removing the path and only keeping the file name, however instead of saving in the "current folder", it saves in documents... Anyway, this isn't a solution, as I still need it to save on the path. But it tells me the problem is in the path itself, either strPath, or \Transmittals\.




    EDIT: wow, I'm an idiot. Wrong folder name on desktop....was supposed to be Transmittals v2...... problem solved!
    Last edited by Taemex; 12-13-2014 at 01:49 PM. Reason: silly mistake

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA ActiveWorkbook.SaveAs - problems with paths: mapped vs. UNC
    By kaptenstofil in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-05-2014, 02:01 PM
  2. SaveAs via VBA code
    By ainnocent1983 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2010, 06:22 AM
  3. SaveAs Code
    By Dohko in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2007, 03:29 PM
  4. SaveAs code
    By wmjenner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-28-2007, 12:35 PM
  5. Problems using SaveAs and SaveCopyAs
    By PromisedOyster in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2005, 01:05 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