Results 1 to 6 of 6

Thread: [RESOLVED] New to VBScript - VS 2022 for editing/debug

  1. #1

    Thread Starter
    New Member ksor's Avatar
    Join Date
    Oct 2022
    Posts
    13

    Resolved [RESOLVED] New to VBScript - VS 2022 for editing/debug

    I'm new to VBScript and want to use VS2022 for my editing/debug.

    I have been using VB, .NET, VS and others on and off for 30 years.
    Now I want to automate my backup of Outlook for me and my wife every sunday.
    Something like:
    1) shut down Outlook if it's running
    2) copy the datafile to my NAS-drive
    3) start Outlook again
    4) send a mail showing if it's was done or not

    I have set up VS2022 for debugging VBScript but it just says:

    'cscript.exe' (Script): Loaded 'Script Code (C:\Windows\System32\cscript.exe)'.
    The program '[14188] cscript.exe' has exited with code 1 (0x1).

    when running my VERY simple script:

    Code:
    Option explicit
    ' Dette script søger for kopiering af Outlooks datafil
    ' Det sker via Opgavestyring hver SØNDAG
    '
    Dim fraFil
    Dim tilFil
    fraFil = "C:\Users\kelds\AppData\Local\Microsoft\Outlook\keld.soerensens@gmail.com(2).ost"
    tilFil = "X:\2 - Måneds\KS Outlook\keld.soerensens@gmail.com(2).ost"
    '
    ' MsgBox("Er du klar ? ")
    
    'copy dataFilNavn tilFil
    
    MsgBox("Nu kopieres: " & fraFil & vbLf & " til " & vbLf & & tilFil & " !")
    Too, I CAN'T step thrugh the script - what do I do wrong ?

  2. #2
    Frenzied Member
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    1,617

    Re: New to VBScript - VS 2022 for editing/debug

    Someone will help you with debugging the vbScript in VS2022 but you could well debug it in VB6?
    Perhaps instead use the Windows scheduler to run a simple batch file to do the copying instead? That is what I have always used BATch for.

    In any case it looks as if you have too many '&' in your msgbox.
    By the power invested in me, all the threads I start are Niya and Olaf free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  3. #3

    Thread Starter
    New Member ksor's Avatar
    Join Date
    Oct 2022
    Posts
    13

    Re: New to VBScript - VS 2022 for editing/debug

    THX for your reply - I too have used BATCH-file and Scheduler, but I've had some mysterious issues combining Scheduler and Batch-files.

    In the first place I made a C# program that did it all very nice - but then Google requested 2-layer logon for me to use Outlook/Google mail in combination and it's a mess to set up.
    When I managed Google stopped supporting the POP-protokol and the new one is a mess too !

    I'm so sick and tired of IT ... I've been struckling with that _BEEP_ all my life !

    I thought VBScript was and simpler solution ... but Gabriel, blow your horn

    but I'll try anyway

  4. #4

    Thread Starter
    New Member ksor's Avatar
    Join Date
    Oct 2022
    Posts
    13

    Re: New to VBScript - VS 2022 for editing/debug

    Why is it so damn hard to get Outlook runing again !

    This snip of code says Outlook is already in use and it is NOT - I've seen it stop by stepping through the code !

    Code:
    
    Set objOutlook = CreateObject("Outlook.Application")
    objOutlook.Quit
    .
    (some more code for copying !)
    .
    .
    .
    
    Msgbox "Start Outlook again !"
    OpenOutlook
     
    
    Sub OpenOutlook()
    
      Dim oApp
      Dim oName
      Dim oFolder
    
      Set oApp = CreateObject("Outlook.Application") 
      Set oName = oApp.GetNamespace("MAPI")
    '  OName.Logon "Default Outlook Profile",, False, True
    '  Set oFolder = oName.GetDefaultFolder(6)
    '  oFolder.Display
      OApp.ActiveExplorer.Activate
    
      Set oApp = Nothing
      Set oName = Nothing
      Set oFolder = Nothing
    
    End Sub
    What do I do wrong ?

  5. #5
    Frenzied Member
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    1,617

    Re: New to VBScript - VS 2022 for editing/debug

    You are in danger of overloading this thread. The title is "...VS 2022 for editing/debug" but it actually pertains to using and debugging VBscript in VS 2022 whilst you also have scripting issues. Then you have additional queries about stopping/starting outlook. Ideally you should have a single thread on this forum for each separate problem that you encounter and cannot work past.

    In that way the right person will identify your issue as one they can contribute to.

    I will bow out now and allow you to create new posts with appropriately named titles and I hope you find some useful assistance.
    By the power invested in me, all the threads I start are Niya and Olaf free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  6. #6

    Thread Starter
    New Member ksor's Avatar
    Join Date
    Oct 2022
    Posts
    13

    Re: New to VBScript - VS 2022 for editing/debug

    Maybe ... no, you ARE right !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width