DDE Request - Does not work when a sheet name contains &quot

GeoffA

New Member
Joined
Dec 12, 2005
Messages
3
Undertaking a DDE Request to Excel from Access using VB in Access 2000, the "intChan1 = DDEInitiate("Excel", strSheetName)" command seems to fail if one of the worksheets in the workbook contains a "-" (Even if this is not one that you are initiating). How can you get round this please.

The code that I am using is:

Sub LoadExcel(filename, sheetname1, sheetname2)

Dim intI As Integer
Dim intChan1 As Long

Dim strResp As String
Dim CellToGet As String
Dim strstr As String
Dim strSheetName As String
Dim strTopics As String
Dim comments As String
Dim VariantArray As Variant

On Error GoTo zz ' Set up error handling.

' Create new worksheet.

intChan1 = DDEInitiate("Excel", "System")
tls = "[open(""" & filename & """,FALSE,FALSE)]"
DDEExecute intChan1, tls

' Get topic list, worksheet name.

info = DDERequest(intChan1, "SysItems")
VariantArray = DDERequest(intChan1, "Topics")
strTopics = DDERequest(intChan1, "Selection")
strSheetName = Left(strTopics, InStr(1, strTopics, "]")) & sheetname1
DDETerminate intChan1

' Establish link with specific worksheet - this next command fails with an error 282

intChan1 = DDEInitiate("Excel", strSheetName)

......
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top