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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,056
Messages
5,835,158
Members
430,342
Latest member
Sailingexcel

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
Top