0

I'm rewriting a plugin for a legacy application (aware this is not safe or best practice) where a user will be able to click a macro, pass a local word document into a C# app. In the app they will be able select a database record and do some basic data entry then save the document to a UNC File Path and insert a pointer into the DB. I have the above working with the code below.

At this point this I need to take this dynamiclly generated UNC path and set the Active.Document path back to the new UNC path. My question is what is the most elegant, non fragile way to do this ? My first thought is to try and have a while loop in the macro that checks if the C# app is running and checks a file for the path but this seems rather clunky. I admitidly havent done any VBA programming in quite some times so I'm not aware of the limitations in returning a variable from the Shell command.

enter image description here

Sub TMSAVE_WAT()
    Dim filePath As String, fileName As String, progName As String
    progName = "C:\dev\deb\TMSave.exe "
    filePath = ActiveDocument.Path
    fileName = ActiveDocument.Name             
   
    Call Shell("""" & progName & """ """ & filePath & """ """ & fileName & """", 
vbNormalFocus)

    'TODO GET UNC AND CHANGE ACTIVE PATH
    '
                      
End Sub
bumble_bee_tuna
  • 3,535
  • 7
  • 42
  • 78

0 Answers0