Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

The item this shortcut refers to has been changed or moved

Posted on 2009-03-30
13
Medium Priority
?
2,618 Views
Last Modified: 2013-11-27
I use the code below to create a desktop shortcut using WScript.shell. It creates the desktop icon successfully. When I double click the icon to log in to the database, I ge the message that it can;t find the mdw named in the TargetPath. This TargetPath string is exactly the same as the target path of the icon I created manually/ Why does it say it can;t find the mdw when it is in fact in the named folder? Am I doing something wrong with the properties when I create the icon?
Dim myWSH as object
Dim strAccessPath As String
Dim strShortcutTarget As String
 
Set myWSH = CreateObject("WScript.Shell")
strAccessPath = myWSH.RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Office\11.0\Access\InstallRoot\Path")
strAccessPath = strAccessPath & "MSACCESS.EXE"
strShortcutTarget = Chr$(34) & strAccessPath & Chr$(34) & " " & Chr$(34) & "C:\BWPhysicianOrg\BWPOBillingCoding.mdb" & Chr$(34) _
 & " /wrkgrp " & Chr$(34) & "C:\BWPhysicianOrg\BWPOBillingCoding.mdw" & Chr$(34)
 
Set WSHShortcut = myWSH.CreateShortcut("C:\Documents and Settings\All Users\Desktop\Appeals Database.lnk")
With WSHShortcut
    .TargetPath = strShortcutTarget
    .IconLocation = strAccessPath & ",1"
    .WorkingDirectory = "C:\"
    .Save
End With
Set myWSH = Nothing
Set WSHShortcut = Nothing

Open in new window

0
Comment
Question by:paulmcneil
  • 7
  • 5
13 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 24019457
Im thinking  this might need to be broken down

strShortcutTarget should be strAccessPath

And I think there is another property you can set called Arguments

so

.Arguments = "C:\BWPhysicianOrg\BWPOBillingCoding.mdb /wrkgrp C:\BWPhysicianOrg\BWPOBillingCoding.mdw"


0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24019722
I'm just wondering why you need code to create a shortcut?
0
 

Author Comment

by:paulmcneil
ID: 24019914
I've isolated the problem. My shortcut string has the forward slash for the wrkgrp switch and that / keeps getting converted to a back slash by the TargetPath property even if a I use the ascii code for /, it still flips the / to \.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 65

Expert Comment

by:rockiroads
ID: 24019946
try escaping it

did it work using .Arguments ?
0
 

Author Comment

by:paulmcneil
ID: 24020300
rockiroads,
What do you mean trying escaping it?
0
 

Author Comment

by:paulmcneil
ID: 24020349
Escaping does not work
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24020360
Put a \ before the /
like this   \/wrkgrp

eg

strShortcutTarget = Chr$(34) & strAccessPath & Chr$(34) & " " & Chr$(34) & "C:\BWPhysicianOrg\BWPOBillingCoding.mdb" & Chr$(34) _
 & " \/wrkgrp " & Chr$(34) & "C:\BWPhysicianOrg\BWPOBillingCoding.mdw" & Chr$(34)
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24020376
yes your right, I just tried it
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24020403
but using .arguments like I said earlier seems to do the trick. I just gave it a test

strShortcutTarget = Chr$(34) & strAccessPath & Chr$(34)
strArguments = Chr$(34) & "C:\BWPhysicianOrg\BWPOBillingCoding.mdb" & Chr$(34) _
 & " /wrkgrp " & Chr$(34) & "C:\BWPhysicianOrg\BWPOBillingCoding.mdw" & Chr$(34)
 
Set WSHShortcut = myWSH.CreateShortcut("C:\Documents and Settings\All Users\Desktop\Appeals Database.lnk")
With WSHShortcut
    .TargetPath = strShortcutTarget
    .Arguments = strArguments

0
 

Author Comment

by:paulmcneil
ID: 24020566
rockiroads,

Now I'm using this test code and it doesn't create the shortcut at all.
Dim myWSH As Object
Dim wshshortcut As Object
Dim fs As Object
 
Set fs = CreateObject("Scripting.FileSystemObject")
 
If fs.FileExists("C:\Documents and Settings\All Users\Desktop\Appeals Database.lnk") = True Then
  fs.deletefile ("C:\Documents and Settings\All Users\Desktop\Appeals Database.lnk")
End If
 
Set myWSH = CreateObject("WScript.Shell")
 
strShortcutTarget = Chr$(34) & strAccessPath & Chr$(34)
strArguments = Chr$(34) & "C:\BWPhysicianOrg\BWPOBillingCoding.mdb" & Chr$(34) _
 & " /wrkgrp " & Chr$(34) & "C:\BWPhysicianOrg\BWPOBillingCoding.mdw" & Chr$(34)
 
Set wshshortcut = myWSH.CreateShortcut("C:\Documents and Settings\All Users\Desktop\Appeals Database.lnk")
With wshshortcut
    .TargetPath = strShortcutTarget
    .Arguments = strArguments
End With

Open in new window

0
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 24020626
I took your original code that you posted and added just strArguments

Dim myWSH As Object
Dim strAccessPath As String
Dim strShortcutTarget As String
Dim WSHShortcut
Dim strArguments As String
 
Set myWSH = CreateObject("WScript.Shell")
strAccessPath = myWSH.RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Office\11.0\Access\InstallRoot\Path")
strAccessPath = strAccessPath & "MSACCESS.EXE"
strShortcutTarget = Chr$(34) & strAccessPath & Chr$(34)
strArguments = Chr$(34) & "C:\BWPhysicianOrg\BWPOBillingCoding.mdb" & Chr$(34) _
 & " /wrkgrp " & Chr$(34) & "C:\BWPhysicianOrg\BWPOBillingCoding.mdw" & Chr$(34)
 
Set WSHShortcut = myWSH.CreateShortcut("C:\Documents and Settings\All Users\Desktop\Appeals Database.lnk")
With WSHShortcut
    .TargetPath = strShortcutTarget
    .Arguments = strArguments
    .IconLocation = strAccessPath & ",1"
    .WorkingDirectory = "C:\"
    .Save
End With
Set myWSH = Nothing
Set WSHShortcut = Nothing


And it created a shortcut (I deleted it first) with a target path of

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "C:\BWPhysicianOrg\BWPOBillingCoding.mdb" /wrkgrp "C:\BWPhysicianOrg\BWPOBillingCoding.mdw"

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24020637
in the last code you posted, you had forgotten to add

.Save

also did you intentionally remove the stting of the icon and working directory?
0
 

Author Closing Comment

by:paulmcneil
ID: 31564330
thanks rockiroads I really appreciate it
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question